/* DocMatch Admin Panel Styles */

:root {
    --color-primary: #4F46E5;
    --color-primary-dark: #4338CA;
    --color-primary-light: #EEF2FF;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-border: #E2E8F0;
    --color-text: #1E293B;
    --color-text-secondary: #64748B;
    --color-success: #16A34A;
    --color-success-bg: #DCFCE7;
    --color-warning: #D97706;
    --color-warning-bg: #FEF3C7;
    --color-danger: #DC2626;
    --color-danger-bg: #FEE2E2;
    --color-info: #2563EB;
    --color-info-bg: #DBEAFE;
    --sidebar-width: 250px;
    --header-height: 56px;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ============================================================
   Login Screen
   ============================================================ */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
}

.login-card {
    background: var(--color-surface);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .login-icon {
    display: inline-block;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

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

#login-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--color-text-secondary);
}

#login-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-family);
    transition: border-color 0.15s;
}

#login-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.login-error {
    color: var(--color-danger);
    font-size: 0.875rem;
    min-height: 1.25rem;
    margin: 0.5rem 0;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #CBD5E1;
}

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

.btn-success:hover:not(:disabled) {
    background: #15803D;
}

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

.btn-danger:hover:not(:disabled) {
    background: #B91C1C;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 6px;
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    transition: background-color 0.15s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ============================================================
   App Shell Layout
   ============================================================ */

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

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    z-index: 200;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
}

.mobile-title {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-text);
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    z-index: 300;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.sidebar-brand {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.sidebar-close-btn {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    color: #CBD5E1;
    cursor: pointer;
    padding: 0.25rem;
}

.nav-list {
    list-style: none;
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: #CBD5E1;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    transition: background-color 0.15s, color 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-family);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-link.active {
    background: var(--color-primary);
    color: #fff;
}

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

.logout-link:hover {
    background: rgba(220, 38, 38, 0.2);
    color: #FCA5A5;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 250;
}

/* ============================================================
   Main Content
   ============================================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-width: 0;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

/* ============================================================
   Stats Grid
   ============================================================ */

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

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

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--color-primary-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

/* ============================================================
   Dashboard Sections
   ============================================================ */

.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.dashboard-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
}

.dashboard-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
}

/* ============================================================
   Toolbar (Search, Filters)
   ============================================================ */

.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.625rem 0.75rem 0.625rem 2.5rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: var(--font-family);
    transition: border-color 0.15s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.filter-group select {
    padding: 0.625rem 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: var(--font-family);
    background: var(--color-surface);
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tr:nth-child(even) {
    background: #F8FAFC;
}

.data-table tr:hover {
    background: var(--color-primary-light);
}

.data-table td {
    border-bottom: 1px solid var(--color-border);
}

.data-table .actions-cell {
    display: flex;
    gap: 0.375rem;
}

/* ============================================================
   Status Badges
   ============================================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.badge-neutral {
    background: #F1F5F9;
    color: var(--color-text-secondary);
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pagination-info {
    color: var(--color-text-secondary);
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.pagination-controls button {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font-family);
    color: var(--color-text);
    transition: background-color 0.15s, border-color 0.15s;
}

.pagination-controls button:hover:not(:disabled) {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.pagination-controls button.active-page {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.pagination-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--color-surface);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

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

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

.modal-body {
    padding: 1.25rem;
}

.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: var(--font-family);
    resize: vertical;
    min-height: 80px;
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.modal-body p {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

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

/* ============================================================
   Toast Notifications
   ============================================================ */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 0.875rem;
    max-width: 360px;
    pointer-events: auto;
    animation: slideIn 0.25s ease;
}

.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast-error {
    border-left: 4px solid var(--color-danger);
}

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

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* ============================================================
   Spinner
   ============================================================ */

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================================
   Responsive: < 1024px (mobile/tablet)
   ============================================================ */

@media (max-width: 1023px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(var(--header-height) + 1rem);
    }

    .dashboard-sections {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* ============================================================
   375px: Small phones
   ============================================================ */

@media (max-width: 375px) {
    .main-content {
        padding: 0.75rem;
        padding-top: calc(var(--header-height) + 0.75rem);
    }

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

    .stat-card {
        padding: 1rem;
    }

    .login-card {
        padding: 1.5rem 1.25rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: none;
    }
}

/* ============================================================
   768px: Tablet
   ============================================================ */

@media (min-width: 768px) and (max-width: 1023px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .main-content {
        padding: 1.5rem;
        padding-top: calc(var(--header-height) + 1.5rem);
    }
}

/* ============================================================
   1024px: Small desktop, sidebar visible
   ============================================================ */

@media (min-width: 1024px) {
    .mobile-header {
        display: none;
    }

    .sidebar-close-btn {
        display: none;
    }
}

/* ============================================================
   1440px: Standard desktop
   ============================================================ */

@media (min-width: 1440px) {
    .main-content {
        padding: 2.5rem 3rem;
    }
}

/* ============================================================
   1920px: Full HD
   ============================================================ */

@media (min-width: 1920px) {
    .main-content {
        padding: 2.5rem 4rem;
    }

    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ============================================================
   2560px: Ultra-wide / 4K
   ============================================================ */

@media (min-width: 2560px) {
    .main-content {
        padding: 3rem 5rem;
    }

    .dashboard-sections {
        grid-template-columns: 1fr 1fr;
    }
}
