/* IFP Design System — Based on Premium Visual Brief */
:root {
    --bg: #f9fafb;
    --panel: #ffffff;
    --muted: #6b7280;
    --text: #111827;
    --line: #e5e7eb;
    /* Better block definition */
    --line-active: #d1d5db;
    --brand: #111827;

    /* Premium Shadows — Diffuse & Soft */
    --shadow-base: 0 1px 3px rgba(17, 24, 39, .07);
    --shadow-md: 0 6px 16px rgba(17, 24, 39, .06);
    --shadow-lg: 0 10px 40px rgba(17, 24, 39, .1);

    --radius: 16px;
    --radius-sm: 12px;
    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
    margin: 0;
}

/* Auth / Login Container — Premium Minimalist */
.login-container {
    background: var(--panel);
    padding: 48px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    width: 90%;
    border: 1px solid var(--line);
    margin: 100px auto;
}

.login-container h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}

.login-container p {
    color: var(--muted);
    font-size: 17px;
    margin-bottom: 32px;
}

#loginForm input {
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    background: #fff;
}

#loginForm input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.04);
}

#loginForm button {
    padding: 14px;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: var(--transition);
    margin-top: 8px;
}

#loginForm button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Dashboard Layout — Pro Dashboard */
.dashboard {
    background: transparent;
    /* Changed to transparent, components will be in cards */
    width: min(1400px, calc(100% - 40px));
    margin: 40px auto;
    border-radius: 0;
    border: none;
    box-shadow: none;
    min-height: 80vh;
}

.dashboard-panel {
    background: var(--panel);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-base), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    padding: 32px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.dashboard-panel:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dashboard header {
    padding: 0 0 32px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 15.5px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--text);
}

/* Upload Zone — Technical Focus */
.upload-zone {
    background: var(--panel);
    padding: 64px 32px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    border: 2px dashed var(--line);
    text-align: center;
    transition: var(--transition);
}

.upload-zone:hover {
    border-color: var(--brand);
    background: #fbfbfc;
}

.upload-zone h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
}

#analyzeBtn {
    padding: 14px 32px;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    font-size: 17px;
    font-family: 'Outfit', sans-serif;
    transition: var(--transition);
}

/* Stats & History — Compact Dashboard Look */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--panel);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-base);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--brand);
    display: block;
    font-family: 'Outfit', sans-serif;
}

.stat-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-container {
    background: var(--panel);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-base);
    overflow: hidden;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    background: #f9fafb;
    padding: 16px 24px;
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--line);
}

.history-table td {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    color: var(--text);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover td {
    background: #fbfbfc;
}

/* Result — Clean Code Look */
.analysis-result pre {
    background: #000;
    color: #fff;
    padding: 24px;
    border-radius: 12px;
    font-family: 'Fira Code', monospace;
    font-size: 15px;
    line-height: 1.6;
    overflow-x: auto;
}

/* Tabs — Clean Navigation */
.tabs {
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 32px;
}

.tab-btn {
    padding: 14px 24px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    color: var(--muted);
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 700;
}

/* User Avatar (Premium Style) */
.user-avatar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    padding: 8px 16px;
    border-radius: 100px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 15px;
    font-weight: 700;
    transition: var(--transition);
    box-shadow: var(--shadow-base);
}

.user-avatar-btn:hover {
    border-color: var(--line-active);
    box-shadow: var(--shadow-md);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
}

@media (max-width: 768px) {
    .dashboard main {
        padding: 20px;
    }

    .stats {
        flex-direction: column;
        gap: 20px;
    }

    .nav-text-desktop {
        display: none;
    }

    .header-nav {
        display: none;
    }
}

/* Premium Global Footer */
.app-footer {
    width: 100%;
    padding: 0 16px;
    border-top: 1px solid var(--line);
    background: #fff;
    margin-top: 64px;
}

.app-footer .container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 22px 0 20px;
}

.app-footer .footer-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    flex-wrap: wrap;
}

.app-footer .footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-weight: 800;
    font-size: 1.25rem;
    font-family: 'Outfit', sans-serif;
    color: var(--text);
    letter-spacing: -0.02em;
}

.app-footer .footer-brand i {
    flex: 0 0 auto;
}

.app-footer .footer-brand span {
    line-height: 1.2;
}

.app-footer .footer-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px 18px;
    flex-wrap: wrap;
}

.app-footer .footer-links a {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--transition);
}

.app-footer .footer-links a:hover {
    color: var(--text);
}

.app-footer .footer-bottom {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.app-footer .footer-bottom p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
    font-weight: 500;
}

@media (max-width: 768px) {
    .app-footer {
        padding: 0 14px;
    }

    .app-footer .container {
        padding: 18px 0;
    }

    .app-footer .footer-top {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .app-footer .footer-links {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .app-footer .footer-links {
        gap: 8px 14px;
    }

    .app-footer .footer-links a {
        font-size: 13px;
    }

    .app-footer .footer-bottom p {
        font-size: 12px;
    }
}

/* Modal — Perfectly Centered & Premium */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    /* Controlled by JS: use flex to center */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 24px;
}

.modal-content {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    position: relative;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close-modal {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 24px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
}

.modal-content h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    font-family: 'Outfit', sans-serif;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-content input {
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}

.modal-content input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.04);
}

.modal-content p {
    text-align: center;
    margin-top: 24px;
    color: var(--muted);
    font-size: 16px;
}

.modal-content p a {
    color: var(--brand);
    font-weight: 700;
    text-decoration: none;
}

@media (max-width: 768px) {
    .modal {
        padding: 16px;
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        padding: 32px 24px 24px;
        border-radius: 18px;
        box-sizing: border-box;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }

    .close-modal {
        top: 16px;
        right: 16px;
        font-size: 22px;
    }

    .modal-content h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .modal-content form {
        gap: 14px;
    }

    .modal-content input {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px;
    }

    .modal-content form button,
    .modal-content .btn-primary,
    .modal-content .btn-login,
    .modal-content .btn-logout {
        width: 100%;
        box-sizing: border-box;
        justify-content: center;
    }

    .modal-content p {
        font-size: 15px;
        line-height: 1.5;
        margin-top: 18px;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 12px;
    }

    .modal-content {
        padding: 28px 16px 18px;
        border-radius: 16px;
        max-height: calc(100vh - 24px);
    }

    .close-modal {
        top: 14px;
        right: 14px;
        font-size: 20px;
    }

    .modal-content h2 {
        font-size: 22px;
        margin-bottom: 18px;
    }

    .modal-content input {
        padding: 13px 14px;
        font-size: 16px;
    }

    .modal-content p {
        font-size: 14px;
        margin-top: 16px;
    }
}
