/* ===== DESIGN TOKENS ===== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --accent: #7c3aed;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --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,.12);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --sidebar-w: 200px;
    --topbar-h: 52px;
}

/* ===== RESET ===== */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: 'Outfit', sans-serif;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===== GLASS BG ===== */
.glass-bg { display: none; }

/* ===== TOP BAR ===== */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 900;
    gap: 1rem;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.topbar-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1100;
    overflow: hidden;
}
.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 0.875rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    text-align: center;
}
.sidebar-logo img { height: 44px; border-radius: 6px; }
.avatar {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: .5px;
    flex-shrink: 0;
}
.sidebar-logo .brand-name {
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--text);
    line-height: 1.25;
}
.sidebar nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.625rem 0.5rem;
    overflow-y: auto;
}
.sidebar nav a,
.sidebar nav button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.sidebar nav a:hover,
.sidebar nav button:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sidebar nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.sidebar-year {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-year label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 0.25rem;
}

/* ===== LAYOUT BODY ===== */
@media (min-width: 900px) {
    body { padding-left: var(--sidebar-w); padding-top: var(--topbar-h); }
}
.page-content {
    padding: 1rem 1.25rem 4rem;
    min-height: calc(100vh - var(--topbar-h));
}

/* ===== FILTER CARD ===== */
.filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.875rem;
    box-shadow: var(--shadow-sm);
}
.filter-card .f-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.filter-card .f-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.filter-card .f-grow { flex: 1; min-width: 140px; }
.filter-card .f-sm  { width: 80px; }
.filter-card .f-md  { width: 110px; }
.filter-actions { display: flex; gap: 0.4rem; align-items: flex-end; margin-left: auto; }

/* ===== STATS ===== */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-value small { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }
.stat-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* ===== INPUTS ===== */
.input {
    width: 100%;
    padding: 0.45rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.input[type="checkbox"] { width: auto; }

/* ===== ACTIONS BAR ===== */
.actions-bar {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 0.625rem;
}
.actions-bar .fab {
    position: static;
    padding: 0.45rem 0.875rem;
    font-size: 0.8125rem;
    border-radius: var(--radius);
    box-shadow: none;
    font-weight: 600;
}

/* ===== FAB ===== */
.fab {
    position: fixed;
    bottom: 2rem; right: 2rem;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, box-shadow .15s, transform .15s;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.fab:hover { background: var(--primary-hover); box-shadow: 0 6px 20px rgba(37,99,235,.4); transform: translateY(-1px); }
.fab svg { width: 1rem; height: 1rem; }

/* ===== TABLE ===== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    min-height: 350px;
}
.document-list {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* Default indexed table is fixed */
    min-width: 1000px;
}
.document-list.auto-layout {
    table-layout: auto;
    min-width: 100%;
}
.document-list thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    text-align: left;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
    white-space: nowrap;
}
.document-list thead th a {
    color: inherit;
    text-decoration: none;
}
.document-list thead th a:hover { color: var(--primary); }
.document-list td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.document-list tr:last-child td { border-bottom: none; }
.document-list tbody tr:hover td { background: #f8faff; }
.document-list .doc-name-cell { color: var(--text); font-weight: 500; }
.document-list .doc-name-cell a { color: var(--primary); }

/* Hover Info Popup */
.adsoyad-cell { position: relative; cursor: help; overflow: visible !important; }
.hover-info {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 9999;
    width: 220px;
    display: none;
    pointer-events: none;
    white-space: normal;
    text-align: left;
    color: var(--text);
}
.adsoyad-cell:hover .hover-info { display: block; }
.hover-info div { margin-bottom: 6px; font-size: 0.75rem; line-height: 1.4; border-bottom: 1px solid #f1f5f9; padding-bottom: 4px; }
.hover-info div:last-child { margin-bottom: 0; border-bottom: none; }
.hover-info strong { color: var(--primary); font-weight: 700; display: block; font-size: 0.65rem; text-transform: uppercase; margin-bottom: 2px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Column widths - 12 columns layout */
.document-list th:nth-child(1),
.document-list td:nth-child(1)  { width: 35px; } /* Tür */
.document-list th:nth-child(2),
.document-list td:nth-child(2)  { width: 85px; } /* Arşiv No */
.document-list th:nth-child(3),
.document-list td:nth-child(3)  { width: 140px; max-width: 140px; } /* Ad Soyad */
.document-list th:nth-child(4),
.document-list td:nth-child(4)  { width: 110px; } /* TC/VKN */
.document-list th:nth-child(5),
.document-list td:nth-child(5)  { width: 50px; } /* Yıl */
.document-list th:nth-child(6),
.document-list td:nth-child(6)  { width: 75px; } /* Ana/Ek */
.document-list th:nth-child(7),
.document-list td:nth-child(7)  { width: 80px; } /* Alan (m2) */
.document-list th:nth-child(8),
.document-list td:nth-child(8)  { width: 110px; } /* TRGM No */
.document-list th:nth-child(9),
.document-list td:nth-child(9)  { width: 90px; } /* Belgenet */
.document-list th:nth-child(10),
.document-list td:nth-child(10) { width: 100px; } /* Kayıt Tarihi */
.document-list th:nth-child(11),
.document-list td:nth-child(11) { width: 90px; } /* Belge (Görüntüle) */
.document-list th:nth-child(12),
.document-list td:nth-child(12) { width: 220px; text-align: right; white-space: nowrap; } /* İşlemler */

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
}
.badge-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-off { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-ana { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-ek { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }

/* ===== BUTTONS ===== */
.primary-btn {
    padding: 0.45rem 0.875rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background .15s, transform .1s;
    font-family: inherit;
    white-space: nowrap;
}
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.primary-btn:disabled { opacity: .6; cursor: default; transform: none; }

.secondary-btn {
    padding: 0.45rem 0.875rem;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.secondary-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

.view-btn {
    padding: 0.35rem 0.75rem;
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    color: var(--primary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    transition: background .15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}
.view-btn:hover { background: #dbeafe; }

/* ===== LOGIN & ADMIN PANEL ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    position: relative;
    overflow: hidden;
}

/* ===== PRINT STYLES ===== */
@media print {
    body * { visibility: hidden; }
    #printArea, #printArea * { visibility: visible; }
    #printArea {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block !important;
    }
    .print-label {
        width: 80mm; /* Standart etiket genişliği */
        margin: 0 auto;
        padding: 10mm;
        border: 1px solid #eee;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }
    .print-label h2 {
        font-size: 14pt;
        text-align: center;
        margin: 0 0 5mm 0;
        text-transform: uppercase;
    }
    .print-label hr { border: 0; border-top: 1px solid #000; margin-bottom: 5mm; }
    .print-label .p-row {
        font-size: 11pt;
        margin-bottom: 3mm;
        display: flex;
        justify-content: space-between;
    }
    .print-label .p-row strong { font-weight: 700; width: 40%; }
    .print-label .p-row span { flex: 1; text-align: left; }
}

#printArea { display: none; }
.login-page::before {
    content:''; position:absolute; width:400px; height:400px;
    background:var(--primary); filter:blur(100px); opacity:0.1;
    border-radius:50%; top:-100px; left:-100px;
}
.login-page::after {
    content:''; position:absolute; width:300px; height:300px;
    background:var(--accent); filter:blur(100px); opacity:0.1;
    border-radius:50%; bottom:-50px; right:-50px;
}
.login-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 10;
    text-align: center;
}
.login-header {
    margin-bottom: 2rem;
}
.login-header h2 {
    color: var(--text);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.login-form .input-group {
    text-align: left;
    margin-bottom: 1.25rem;
}
.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.login-form .input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    transition: all 0.2s;
}
.login-form .input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.login-btn {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}
.login-footer {
    margin-top: 1.5rem;
    font-size: 0.875rem;
}
.login-footer a {
    color: var(--text-muted);
    transition: color 0.2s;
}
.login-footer a:hover {
    color: var(--primary);
}

/* ===== CARD ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    box-shadow: var(--shadow-sm);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(3px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalIn .2s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.96) translateY(-8px); }
    to   { opacity: 1; transform: none; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.close-modal {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    border-radius: var(--radius);
    transition: background .15s;
}
.close-modal:hover { background: var(--surface-2); }

.modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--border);
}
.modal-content label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* ===== SCAN STATUS ===== */
.scan-status {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.loader {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview-area { width: 100%; }
.error-msg { text-align: center; padding: 2rem; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    background: #1e293b;
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 3000;
    animation: toastIn .25s ease-out;
}
@keyframes toastIn {
    from { transform: translateX(120%); opacity:0; }
    to   { transform: none; opacity:1; }
}

/* ===== EMPTY STATE ===== */
.no-files { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.no-files img { width: 10rem; margin-bottom: 1rem; opacity: .6; }

/* ===== FOOTER ===== */
.footer-bar {
    position: fixed;
    left: var(--sidebar-w); right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.35rem 1rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-align: center;
    z-index: 900;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    margin-top: 0.75rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== HAMB ===== */
.hamb {
    position: fixed;
    top: 10px; left: 10px;
    z-index: 1200;
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* ===== DARK MODE ===== */
body.dark {
    --bg: #0a0f1a;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: #1e293b;
    --border-strong: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --primary-light: #1e2d4f;
}
body.dark .glass-bg { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 899px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); transition: transform .2s; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body { padding-left: 0; padding-top: var(--topbar-h); }
    .topbar { left: 0; }
    .footer-bar { left: 0; }
}

.loader-sm {
    width: 14px;
    height: 14px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #6366f1;
    border-radius: 50%;
    display: inline-block;
    animation: spin-sm 1s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes spin-sm {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
