/* admin.css - Sleek Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Background and Surface - Creating clear depth (UX) */
    --background: #0f172a;       /* Slate 900 */
    --surface: #1e293b;          /* Slate 800 */
    --surface-hover: #334155;    /* Slate 700 */
    
    /* Text Colors - High contrast for readability */
    --foreground: #f8fafc;       /* Slate 50 */
    --muted: #94a3b8;            /* Slate 400 */
    
    /* Borders and Inputs - Clear boundaries */
    --border: #334155;           /* Slate 700 */
    
    /* Interactive Elements - Clear affordances */
    --primary: #f8fafc;
    --primary-foreground: #0f172a;
    
    --accent: #10b981;           /* Emerald 500 - easier on the eyes than pure green */
    --accent-hover: #059669;     /* Emerald 600 */
    --accent-foreground: #ffffff;
    
    /* Status Colors */
    --destructive: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --sidebar-width: 260px;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h5 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    color: var(--foreground);
    letter-spacing: -0.02em;
}

.sidebar-brand small {
    color: var(--muted);
    font-size: 12px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar-nav a:hover {
    color: var(--foreground);
    background-color: var(--surface-hover);
    transform: translateX(4px);
}

.sidebar-nav a.active {
    color: var(--primary-foreground);
    background-color: var(--primary);
    transform: none;
}

.sidebar-nav a.htmx-request {
    background-color: var(--surface-hover);
    color: var(--muted);
    transform: scale(0.98);
    pointer-events: none;
}

.sidebar-nav a.htmx-request::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: menuLoading 1s infinite linear;
}

@keyframes menuLoading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-footer a {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.sidebar-footer a:hover { 
    color: var(--destructive); 
    background-color: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 40px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    font-weight: 600;
    font-size: 24px;
    letter-spacing: -0.02em;
    margin: 0;
}

.page-header p {
    color: var(--muted);
    font-size: 14px;
    margin: 4px 0 0;
}

/* Cards */
.card-dark {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.card-dark .card-body {
    padding: 24px;
}

/* Stat Cards */
.stat-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    border-color: var(--muted);
}

.stat-card-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--foreground);
    line-height: 1;
}

.stat-icon {
    color: var(--muted);
}
.stat-icon svg {
    width: 20px;
    height: 20px;
}

/* Tables */
.table-dark-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-dark-custom thead th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table-dark-custom tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
    color: var(--foreground);
}

.table-dark-custom tbody tr:hover td {
    background-color: var(--surface-hover);
}

.table-dark-custom tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge-status {
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.badge-active { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-inactive { background: rgba(161, 161, 170, 0.15); color: #a1a1aa; }

/* Buttons */
.btn-primary-custom {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    transition: opacity 0.2s;
}

.btn-primary-custom:hover {
    opacity: 0.9;
    color: var(--primary-foreground);
}

.btn-outline-custom {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--foreground);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    transition: background-color 0.2s;
}

.btn-outline-custom:hover {
    background-color: var(--surface-hover);
    color: var(--foreground);
}

.btn-sm-action {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius);
    font-weight: 500;
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--foreground);
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}
.btn-sm-action:hover {
    background-color: var(--surface-hover);
    color: var(--foreground);
}
.btn-sm-action.danger {
    color: var(--destructive);
    border-color: rgba(239, 68, 68, 0.2);
}
.btn-sm-action.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Forms */
.form-control-dark, .form-select-dark {
    background-color: var(--background);
    border: 1px solid var(--border);
    color: var(--foreground);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control-dark:focus, .form-select-dark:focus {
    background-color: var(--background);
    border-color: var(--accent);
    color: var(--foreground);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    outline: none;
}

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

/* Override Bootstrap defaults for dark theme */
.form-control, .form-select, textarea.form-control {
    background-color: var(--background) !important;
    border-color: var(--border) !important;
    color: var(--foreground) !important;
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
    background-color: var(--background) !important;
    border-color: var(--accent) !important;
    color: var(--foreground) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important;
}
.form-control::placeholder, textarea.form-control::placeholder {
    color: var(--muted) !important;
}
.form-label, label.form-label, label {
    color: var(--foreground) !important;
}
.form-check-input {
    background-color: var(--background) !important;
    border-color: var(--border) !important;
    filter: none !important;
}
.form-check-input:checked {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}
.form-check-label {
    color: var(--foreground) !important;
}
.form-check-label small, .form-check-label .text-muted {
    color: var(--muted) !important;
}
.form-select option {
    background-color: var(--surface);
    color: var(--foreground);
}
.form-control:disabled, .form-control[readonly] {
    background-color: var(--surface) !important;
    color: var(--muted) !important;
    opacity: 0.7;
}

/* Pagination */
.pagination .page-link {
    background-color: transparent !important;
    color: var(--muted) !important;
    border-color: var(--border) !important;
}
.pagination .page-link:hover {
    background-color: var(--surface-hover) !important;
    color: var(--foreground) !important;
}
.pagination .page-item.active .page-link {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

/* Modal dark theme */
.modal-content {
    background-color: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--foreground) !important;
}
.modal-header, .modal-footer {
    border-color: var(--border) !important;
}
.modal-title {
    color: var(--foreground) !important;
}
.modal-body label {
    color: var(--foreground) !important;
}

/* Text overrides */
.text-dark {
    color: var(--foreground) !important;
}
.text-light {
    color: var(--foreground) !important;
}

/* Form label dark */
.form-label-dark {
    font-size: 13px;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 8px;
}

/* Alerts / Toasts */
.toast-container-custom {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-custom {
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--foreground);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 300px;
}
.alert-custom.success { border-left: 3px solid var(--accent); }
.alert-custom.danger { border-left: 3px solid var(--destructive); }

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--background);
}
.login-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 40px;
}
.login-card h3 {
    font-weight: 600;
    font-size: 24px;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
}

/* HTMX and general utilities */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

#global-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: transparent;
    z-index: 9999;
}
#global-progress .bar {
    height: 100%;
    background-color: var(--primary);
    width: 0;
    transition: width 0.2s ease;
}
#global-progress.htmx-request .bar {
    width: 50%;
    animation: pulse 1s infinite alternate;
}
@keyframes pulse {
    0% { width: 30%; }
    100% { width: 70%; }
}

/* Main Content Loading Overlay (Spinner) */
.content-spinner-overlay {
    position: fixed;
    top: 50%;
    left: calc(50% + (var(--sidebar-width) / 2));
    transform: translate(-50%, -50%);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

@media (max-width: 768px) {
    .content-spinner-overlay {
        left: 50%;
    }
}

.content-spinner-overlay.htmx-request {
    opacity: 1;
    visibility: visible;
}

/* Page Transitions */
@keyframes slideFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#main-content {
    transition: opacity 0.2s ease-out, filter 0.2s ease-out;
}

#main-content.htmx-request {
    opacity: 0.4;
    filter: blur(2px);
    pointer-events: none;
}

#main-content > * {
    animation: slideFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--background); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Mobile Additions */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
}
.mobile-topbar-brand {
    font-weight: 600;
    font-size: 16px;
}
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--foreground);
    padding: 8px;
    cursor: pointer;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.2s;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 80px 16px 24px; }
    .mobile-topbar { display: flex; }
    .hamburger { display: block; }
    .sidebar-overlay { display: block; pointer-events: none; }
    .sidebar-overlay.active { opacity: 1; pointer-events: auto; }
}
