/* =========================================
   DMS – Site Styles v2
   ========================================= */

/* ---- CSS Variables ---- */
:root {
    --sidebar-width: 256px;
    --topbar-height: 58px;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --sidebar-bg: #0f172a;
    --sidebar-border: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active-bg: rgba(59,130,246,.15);
    --sidebar-active-text: #93c5fd;
    --body-bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.14);
    --t: 0.18s ease;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--text);
    font-size: .9rem;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   SIDEBAR LAYOUT
   ========================================= */

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

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--t);
    overflow: hidden;
}

/* Brand */
.sidebar-brand {
    padding: 1.1rem 1rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    text-decoration: none !important;
}

.brand-logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59,130,246,.4);
}

.brand-name {
    display: block;
    font-size: .95rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.3px;
    line-height: 1.2;
}

.brand-sub {
    display: block;
    font-size: .68rem;
    color: #64748b;
    font-weight: 500;
    max-width: 165px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.brand-img-wrap {
    display: inline-flex;
    align-items: center;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .6rem 0;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
}

.nav-group {
    padding: 0 .65rem .5rem;
}

.nav-group + .nav-group {
    border-top: 1px solid var(--sidebar-border);
    padding-top: .65rem;
    margin-top: .15rem;
}

.nav-group-label {
    display: block;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: #475569;
    padding: .4rem .5rem .3rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .52rem .7rem;
    border-radius: 7px;
    color: var(--sidebar-text);
    text-decoration: none !important;
    font-size: .84rem;
    font-weight: 500;
    transition: background var(--t), color var(--t);
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link i {
    width: 17px;
    text-align: center;
    font-size: .88rem;
    flex-shrink: 0;
    transition: color var(--t);
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #cbd5e1;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.sidebar-link.active i { color: #60a5fa; }

/* Upload accent link */
.sidebar-link-upload {
    background: rgba(59,130,246,.1);
    color: #93c5fd !important;
    border: 1px solid rgba(59,130,246,.18);
    margin-top: .2rem;
}

.sidebar-link-upload i { color: #60a5fa; }

.sidebar-link-upload:hover {
    background: rgba(59,130,246,.2) !important;
    color: #bfdbfe !important;
}

/* ---- Main Area ---- */
.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--t);
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 6px rgba(0,0,0,.05);
    flex-shrink: 0;
}

.topbar-toggle {
    display: none;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    padding: .35rem .45rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--t), color var(--t);
    line-height: 1;
}

.topbar-toggle:hover { background: #f1f5f9; color: var(--text); }

.topbar-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .65rem;
}

/* User chip */
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 50px;
    padding: .28rem .7rem .28rem .28rem;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    transition: background var(--t), border-color var(--t);
    line-height: 1;
}

.user-chip:hover { background: #f1f5f9; border-color: #cbd5e1; }

.user-chip-avatar {
    width: 26px; height: 26px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-chip.dropdown-toggle::after { margin-left: .2rem; }

/* ---- Page Body ---- */
.page-body {
    flex: 1;
    padding: 1.75rem 1.5rem;
}

/* ---- Sidebar Overlay (mobile) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 199;
    opacity: 0;
    transition: opacity var(--t);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .topbar-toggle { display: flex; align-items: center; }
    .topbar-title { font-size: .85rem; }
}

/* =========================================
   COMPONENTS
   ========================================= */

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    animation: fadeUp .2s ease both;
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.1rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-weight: 600;
    font-size: .875rem;
    color: var(--text);
}

.card-header h6 { font-weight: 600; color: var(--text); }

/* ---- Stat Cards ---- */
.stat-card {
    border: none !important;
    border-radius: 14px !important;
    overflow: hidden;
    position: relative;
    transition: transform var(--t), box-shadow var(--t) !important;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .card-body {
    padding: 1.35rem 1.4rem;
    position: relative;
    z-index: 1;
}

.stat-card::before {
    content: '';
    position: absolute;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: rgba(255,255,255,.09);
    right: -25px; top: -25px;
    pointer-events: none;
}

.stat-card::after {
    content: '';
    position: absolute;
    width: 70px; height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    right: 18px; bottom: -18px;
    pointer-events: none;
}

.stat-icon {
    width: 46px; height: 46px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    background: rgba(255,255,255,.2);
    color: white;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: white;
    line-height: 1;
    margin-top: .7rem;
}

.stat-label {
    font-size: .72rem;
    color: rgba(255,255,255,.75);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-top: .2rem;
}

/* Gradient variants */
.stat-blue  { background: linear-gradient(135deg, #3b82f6, #6366f1) !important; box-shadow: 0 8px 24px rgba(59,130,246,.35) !important; }
.stat-green { background: linear-gradient(135deg, #10b981, #0ea5e9) !important; box-shadow: 0 8px 24px rgba(16,185,129,.35) !important; }
.stat-amber { background: linear-gradient(135deg, #f59e0b, #ef4444) !important; box-shadow: 0 8px 24px rgba(245,158,11,.35) !important; }
.stat-rose  { background: linear-gradient(135deg, #ec4899, #8b5cf6) !important; box-shadow: 0 8px 24px rgba(236,72,153,.35) !important; }

/* ---- Tables ---- */
.table {
    font-size: .875rem;
    color: var(--text);
}

.table > thead th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table > tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    border-color: var(--border);
}

.table-hover tbody tr { transition: background var(--t); }
.table-hover tbody tr:hover { background: #f8fafc !important; }

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    letter-spacing: .2px;
    font-size: .74rem;
}

.badge.bg-light {
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    background: #f8fafc !important;
}

/* ---- Buttons ---- */
.btn {
    border-radius: 7px;
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--t);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(59,130,246,.35);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn-sm { border-radius: 6px; font-size: .8rem; }
.rounded-pill { border-radius: 50px !important; }

/* ---- Form Controls ---- */
.form-control, .form-select {
    border-radius: 8px;
    border-color: var(--border);
    font-size: .875rem;
    transition: border-color var(--t), box-shadow var(--t);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.input-group-text {
    border-color: var(--border);
    background: #f8fafc;
    color: var(--muted);
}

/* ---- List Group ---- */
.list-group-item {
    border-color: var(--border);
    font-size: .875rem;
    padding: .6rem 1rem;
    transition: background var(--t);
}

.list-group-item-action:hover { background: #f8fafc; }

.list-group-item.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}

/* ---- Dropdown ---- */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .4rem;
    font-size: .875rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: .45rem .75rem;
    font-size: .875rem;
    transition: background var(--t);
}

.dropdown-item:hover { background: #f1f5f9; }

.dropdown-divider { border-color: var(--border); margin: .3rem .75rem; }

/* ---- Alerts ---- */
.alert {
    border-radius: var(--radius);
    border: none;
    font-size: .875rem;
}

.alert-danger  { background: #fff1f2; color: #be123c; }
.alert-success { background: #f0fdf4; color: #15803d; }
.alert-warning { background: #fffbeb; color: #92400e; }

/* ---- Empty States ---- */
.empty-state {
    padding: 3.5rem 1rem;
    text-align: center;
}

.empty-state i {
    font-size: 2.5rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
    display: block;
}

.empty-state p {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 1.25rem;
}

/* ---- File Icon Colors ---- */
.file-icon-pdf   { color: #ef4444; }
.file-icon-word  { color: #2563eb; }
.file-icon-excel { color: #16a34a; }
.file-icon-image { color: #8b5cf6; }
.file-icon-other { color: #64748b; }

/* ---- Detail Meta ---- */
.detail-meta dt {
    color: var(--muted);
    font-weight: 500;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.detail-meta dd {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text);
}

/* ---- Upload Mode Tabs ---- */
.upload-mode-tabs {
    display: flex;
    gap: .4rem;
    background: #f1f5f9;
    border-radius: 9px;
    padding: .3rem;
    width: fit-content;
}

.mode-tab {
    border: none;
    background: transparent;
    border-radius: 7px;
    padding: .4rem 1rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background var(--t), color var(--t), box-shadow var(--t);
}

.mode-tab.active {
    background: white;
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.mode-tab:not(.active):hover { color: var(--text); }

/* ---- File Tree ---- */
.file-tree-dir {
    padding: .2rem 0;
    font-weight: 600;
    color: var(--text);
}

.file-tree-item {
    padding: .12rem 0;
    color: var(--muted);
}

.file-tree-log {
    max-height: 160px;
    overflow-y: auto;
    font-size: .78rem;
    line-height: 1.6;
}

/* ---- Upload Drop Zone ---- */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--t), background var(--t);
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}

.drop-zone i.upload-icon {
    font-size: 2.5rem;
    color: #94a3b8;
    margin-bottom: .75rem;
    display: block;
    transition: color var(--t);
}

.drop-zone:hover i.upload-icon, .drop-zone.drag-over i.upload-icon {
    color: var(--primary);
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h4, .page-header h5 {
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* ---- Misc ---- */
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
hr { border-color: var(--border); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Animations ---- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================
   LOGIN PAGE
   ========================================= */

.login-page {
    min-height: 100vh;
    display: flex;
}

/* Left: brand panel */
.login-left {
    flex: 1;
    background: linear-gradient(150deg, #0f172a 0%, #1e3a5f 55%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59,130,246,.14) 0%, transparent 70%);
    top: -150px; left: -150px;
    pointer-events: none;
}

.login-left::after {
    content: '';
    position: absolute;
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,.1) 0%, transparent 70%);
    bottom: -100px; right: -80px;
    pointer-events: none;
}

.login-left-content {
    position: relative;
    z-index: 1;
    max-width: 380px;
    text-align: center;
}

.login-logo-wrap {
    display: inline-flex;
    align-items: center;
    margin-bottom: 1.75rem;
}

.login-brand-desc {
    color: #94a3b8;
    font-size: .9rem;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #cbd5e1;
    font-size: .85rem;
    margin-bottom: .8rem;
    font-weight: 500;
}

.login-features li .feat-icon {
    width: 30px; height: 30px;
    background: rgba(59,130,246,.18);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #60a5fa;
    font-size: .8rem;
    flex-shrink: 0;
}

/* Right: form panel */
.login-right {
    width: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: white;
    flex-shrink: 0;
}

.login-form-wrap { width: 100%; max-width: 360px; }

.login-form-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: .25rem;
    letter-spacing: -.3px;
}

.login-form-sub {
    color: var(--muted);
    font-size: .875rem;
    margin-bottom: 2rem;
}

/* Responsive: hide left panel on small screens */
@media (max-width: 768px) {
    .login-left { display: none; }
    .login-right { width: 100%; }
}
