@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==============================
   DESIGN TOKENS
   ============================== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(23, 33, 54, 0.95);
    --bg-input: rgba(6, 10, 23, 0.7);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #a5b4fc;

    --accent-indigo: #6366f1;
    --accent-indigo-hover: #4f46e5;
    --accent-violet: #8b5cf6;
    --accent-cyan: #22d3ee;
    --accent-emerald: #34d399;
    --accent-rose: #f43f5e;
    --accent-rose-hover: #e11d48;
    --accent-amber: #fbbf24;

    --gradient-brand: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --gradient-glow: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.08));

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
    --shadow-glow: 0 0 40px rgba(99,102,241,0.08);

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==============================
   RESET & BASE
   ============================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: #c7d2fe;
}

/* ==============================
   BACKGROUND
   ============================== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 10% 0%, rgba(99,102,241,0.12) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 90% 100%, rgba(139,92,246,0.10) 0%, transparent 60%),
        radial-gradient(ellipse 40% 30% at 50% 50%, rgba(34,211,238,0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* Subtle grain overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* ==============================
   LAYOUT
   ============================== */
.page-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

main {
    flex: 1;
    padding: 2rem 0 4rem;
}

/* ==============================
   NAVBAR
   ============================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.navbar-brand .logo-icon {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 800;
    color: white;
    box-shadow: 0 0 20px rgba(99,102,241,0.3);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}
.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.nav-link.active {
    color: var(--text-primary);
    background: rgba(99,102,241,0.1);
}

/* ==============================
   HERO / PAGE HEADER
   ============================== */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 1.25rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero h1 {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 0.75rem;
    background: linear-gradient(to right, #e2e8f0, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 540px;
    margin: 0 auto;
    line-height: 1.7;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.hero-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* ==============================
   FILE GRID
   ============================== */
.file-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.file-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    transition: all var(--transition-base);
    overflow: hidden;
}

.file-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.file-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.file-card:hover::before {
    opacity: 1;
}

.file-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.file-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    background: var(--gradient-glow);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.file-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.file-card-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.65;
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

.file-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.file-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==============================
   BADGES
   ============================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-open {
    background: rgba(52, 211, 153, 0.1);
    color: var(--accent-emerald);
    border: 1px solid rgba(52, 211, 153, 0.15);
}

.badge-locked {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-amber);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

/* ==============================
   BUTTONS
   ============================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent-indigo);
    color: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover {
    background: var(--accent-indigo-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
    color: white;
}

.btn-ghost {
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.15);
}

.btn-danger {
    background: rgba(244,63,94,0.1);
    color: var(--accent-rose);
    border: 1px solid rgba(244,63,94,0.2);
}
.btn-danger:hover {
    background: var(--accent-rose);
    color: white;
    border-color: var(--accent-rose);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

/* ==============================
   FORMS
   ============================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

input[type="file"].form-control {
    padding: 0.5rem;
    background: transparent;
    border-style: dashed;
    cursor: pointer;
}
input[type="file"].form-control:hover {
    border-color: var(--accent-indigo);
    background: rgba(99,102,241,0.03);
}

/* ==============================
   GLASS PANEL
   ============================== */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.panel-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ==============================
   TABLE
   ============================== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.admin-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-light);
}

.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    vertical-align: middle;
}

.admin-table tbody tr {
    transition: background var(--transition-fast);
}
.admin-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.admin-table .file-title-cell {
    font-weight: 600;
    color: var(--text-primary);
}
.admin-table .file-name-cell {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ==============================
   ALERTS
   ============================== */
.alert {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.15);
    color: #fda4af;
}

.alert-success {
    background: rgba(52, 211, 153, 0.08);
    border-color: rgba(52, 211, 153, 0.15);
    color: #6ee7b7;
}

/* ==============================
   MODAL
   ============================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.close-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition-fast);
}
.close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

/* ==============================
   EMPTY STATE
   ============================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ==============================
   FOOTER
   ============================== */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 2rem 0;
    text-align: center;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-inner a {
    color: var(--text-muted);
}
.footer-inner a:hover {
    color: var(--text-accent);
}

/* ==============================
   ADMIN LAYOUT
   ============================== */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.admin-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.admin-grid {
    display: grid;
    gap: 1.5rem;
}

/* Login card centered */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-card .panel-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.login-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-lg);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 0 30px rgba(99,102,241,0.25);
}

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.5s var(--transition-base) both;
}

.file-card:nth-child(1) { animation-delay: 0.05s; }
.file-card:nth-child(2) { animation-delay: 0.1s; }
.file-card:nth-child(3) { animation-delay: 0.15s; }
.file-card:nth-child(4) { animation-delay: 0.2s; }
.file-card:nth-child(5) { animation-delay: 0.25s; }
.file-card:nth-child(6) { animation-delay: 0.3s; }

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 768px) {
    .container {
        padding: 0 1.25rem;
    }

    .hero {
        padding: 2.5rem 0 2rem;
    }

    .hero-stats {
        gap: 1.5rem;
    }

    .file-grid {
        grid-template-columns: 1fr;
    }

    .footer-inner {
        flex-direction: column;
        gap: 0.5rem;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .navbar-links .nav-link span {
        display: none;
    }
}
