/* PDF Viewer Platform — Admin CSS */

:root {
    --primary:        #4f46e5;
    --primary-dark:   #4338ca;
    --primary-light:  #ede9fe;
    --success:        #10b981;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #3b82f6;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --border:         #e2e8f0;
    --bg:             #ffffff;
    --bg-secondary:   #f8fafc;
    --sidebar-w:      240px;
    --topbar-h:       60px;
    --radius:         8px;
    --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 16px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-secondary);
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-w);
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-logo {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-logo svg { color: var(--primary); flex-shrink: 0; }

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all .15s;
    font-size: .875rem;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; background: rgba(79,70,229,.25); border-left-color: var(--primary); }

.sidebar-footer {
    padding: .75rem 0;
    border-top: 1px solid rgba(255,255,255,.06);
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-topbar {
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.admin-content {
    padding: 1.75rem;
    flex: 1;
}

/* ------------------------------------------------------------------ */
/* Page header                                                         */
/* ------------------------------------------------------------------ */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

/* ------------------------------------------------------------------ */
/* Cards                                                               */
/* ------------------------------------------------------------------ */

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

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

.card-title { font-size: .95rem; font-weight: 600; }

.card-body { padding: 1.25rem; }

/* ------------------------------------------------------------------ */
/* Stats Grid                                                          */
/* ------------------------------------------------------------------ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.green  { background: #f0fdf4; color: #10b981; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon.orange { background: #fff7ed; color: #f59e0b; }

.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ------------------------------------------------------------------ */
/* Grid helpers                                                        */
/* ------------------------------------------------------------------ */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    font-size: .875rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-secondary); }

.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-warning  { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }

.btn-sm  { padding: .4rem .85rem; font-size: .8rem; }
.btn-xs  { padding: .25rem .6rem; font-size: .75rem; }
.btn-xs + .btn-xs { margin-left: .25rem; }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .35rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: .55rem .85rem;
    font-size: .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

select.form-control { cursor: pointer; }

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

.toggle-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    cursor: pointer;
    font-size: .875rem;
}

.toggle-label input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.table th {
    padding: .65rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-secondary); }

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

/* ------------------------------------------------------------------ */
/* Badges                                                              */
/* ------------------------------------------------------------------ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 99px;
}

.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #b91c1c; }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* ------------------------------------------------------------------ */
/* Alerts                                                              */
/* ------------------------------------------------------------------ */

.alert {
    padding: .85rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1.25rem;
}

.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ------------------------------------------------------------------ */
/* User avatar / topbar                                                */
/* ------------------------------------------------------------------ */

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.user-menu { display: flex; align-items: center; gap: .6rem; }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: .875rem; }
.user-role { margin-top: .15rem; }

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
    display: none;
}

/* ------------------------------------------------------------------ */
/* Modal                                                               */
/* ------------------------------------------------------------------ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.open { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(2px);
}

.modal-dialog {
    position: relative;
    background: var(--bg);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-body { padding: 1.25rem; }

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

/* ------------------------------------------------------------------ */
/* Text helpers                                                        */
/* ------------------------------------------------------------------ */

.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }

small.text-muted { font-size: .78rem; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-main {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: flex;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .admin-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ */
/* Motion — subtle micro-interactions                                 */
/* ------------------------------------------------------------------ */

:root {
    --ease-out:      cubic-bezier(.16,1,.3,1);
    --ease-spring:   cubic-bezier(.34,1.56,.64,1);
    --dur-fast:      .15s;
    --dur:           .25s;
    --dur-slow:      .4s;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes softPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
    50%      { box-shadow: 0 0 0 5px rgba(239,68,68,0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Page-level entrance */
.admin-content > .page-header {
    animation: fadeSlideUp var(--dur-slow) var(--ease-out) both;
}

.admin-content > *:not(.page-header) {
    animation: fadeSlideUp var(--dur-slow) var(--ease-out) both;
    animation-delay: .04s;
}

/* Stat cards — gentle stagger */
.stats-grid .stat-card {
    animation: fadeSlideUp var(--dur-slow) var(--ease-out) both;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: .03s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: .08s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: .13s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: .18s; }
.stats-grid .stat-card:nth-child(n+5) { animation-delay: .22s; }

.stat-card {
    transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}
.stat-icon { transition: transform var(--dur-fast) var(--ease-spring); }
.stat-card:hover .stat-icon { transform: scale(1.08) rotate(-3deg); }

/* Cards */
.card {
    transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur), transform var(--dur) var(--ease-out);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

/* Buttons — press feedback + shimmer-free hover lift */
.btn {
    position: relative;
    transform: translateZ(0);
    transition: background-color var(--dur-fast), border-color var(--dur-fast),
                color var(--dur-fast), transform var(--dur-fast) var(--ease-spring),
                box-shadow var(--dur-fast);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,.28); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79,70,229,.28);
}
.btn[disabled] { transform: none !important; }

/* Nav items — smooth active state slide */
.nav-item {
    position: relative;
    overflow: hidden;
}
.nav-item::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform var(--dur) var(--ease-out);
}
.nav-item.active::before { transform: scaleY(1); }
.nav-item span { transition: transform var(--dur-fast) var(--ease-out); }
.nav-item:hover span { transform: translateX(2px); }

/* Sidebar entrance */
.admin-sidebar { animation: fadeIn var(--dur-slow) var(--ease-out) both; }

/* Table rows — staggered reveal, capped so long tables don't lag */
.table tbody tr {
    animation: fadeIn var(--dur) var(--ease-out) both;
}
.table tbody tr:nth-child(1) { animation-delay: .02s; }
.table tbody tr:nth-child(2) { animation-delay: .05s; }
.table tbody tr:nth-child(3) { animation-delay: .08s; }
.table tbody tr:nth-child(4) { animation-delay: .11s; }
.table tbody tr:nth-child(5) { animation-delay: .14s; }
.table tbody tr:nth-child(n+6) { animation-delay: .16s; }

.table tbody tr {
    transition: background-color var(--dur-fast);
}

/* Alerts — slide in */
.alert {
    animation: fadeSlideUp var(--dur) var(--ease-out) both;
}

/* Badges — soft entrance */
.badge { transition: transform var(--dur-fast) var(--ease-spring); }

/* Modal — fade + scale instead of hard cut */
.modal {
    display: flex;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease-out), visibility 0s linear var(--dur);
}
.modal.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--dur) var(--ease-out);
}
.modal-dialog {
    transform: scale(.95) translateY(8px);
    transition: transform var(--dur) var(--ease-spring);
}
.modal.open .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Form controls — focus polish */
.form-control { transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast); }

/* Notification bell */
.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: transparent;
    transition: background-color var(--dur-fast), color var(--dur-fast);
}
.notif-bell:hover { background: var(--bg-secondary); color: var(--text); }
.notif-bell .bell-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border: 2px solid var(--bg);
    border-radius: 50%;
    animation: softPulse 2s ease-in-out infinite;
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(.98);
    transform-origin: top right;
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring), visibility 0s linear var(--dur);
}
.notif-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring);
}
.notif-dropdown-header {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.notif-dropdown-item {
    display: block;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background-color var(--dur-fast);
}
.notif-dropdown-item:last-child { border-bottom: none; }
.notif-dropdown-item:hover { background: var(--bg-secondary); }
.notif-dropdown-item.unread { background: rgba(79,70,229,.04); }
.notif-dropdown-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}
.notif-dropdown-footer {
    padding: .65rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border);
}
.notif-dropdown-footer a {
    color: var(--primary);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}

/* Skeleton loader utility (for future async content) */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, #eef1f6 37%, var(--bg-secondary) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
    border-radius: 6px;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* Spinner utility */
.spin { animation: spin .7s linear infinite; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
