/* =========================================================
   Amintra Unified Design & Theme System (Light & Dark)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- LIGHT THEME (Default :root) --- */
:root {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --bg-surface-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: #f1f5f9;

    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --border-color: #e2e8f0;
    --border-subtle: #edf2f7;
    --border-focus: #3b82f6;

    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.1);

    --accent-color: #0284c7;
    --success-color: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.12);
    --warning-color: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.12);
    --danger-color: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* legacy mapping for existing views */
    --primary-bg: var(--bg-base);
    --secondary-bg: var(--bg-surface);
    --primary-border: var(--border-color);
    --placeholder-color: var(--text-muted);
    --button-bg: var(--primary-color);
    --button-text: #ffffff;
    --link-color: var(--primary-color);
    --shadow-color: rgba(0, 0, 0, 0.08);
}

/* --- DARK THEME (html.dark or [data-theme="dark"]) --- */
html.dark,
[data-theme="dark"] {
    --bg-base: #090d16;
    --bg-surface: #111827;
    --bg-surface-elevated: #1e293b;
    --bg-surface-card: #131c2e;
    --bg-input: #0b1120;
    --bg-hover: rgba(255, 255, 255, 0.05);

    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --border-color: rgba(255, 255, 255, 0.09);
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-focus: #38bdf8;

    --primary-color: #38bdf8;
    --primary-hover: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.15);

    --accent-color: #38bdf8;
    --success-color: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.15);
    --warning-color: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.15);
    --danger-color: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);

    /* legacy mapping for existing views */
    --primary-bg: var(--bg-base);
    --secondary-bg: var(--bg-surface);
    --primary-border: var(--border-color);
    --placeholder-color: var(--text-muted);
    --button-bg: var(--primary-color);
    --button-text: #090d16;
    --link-color: var(--primary-color);
    --shadow-color: rgba(0, 0, 0, 0.6);
}

/* --- GLOBAL RESETS & TYPOGRAPHY --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}

code, kbd, samp, pre {
    font-family: 'JetBrains Mono', monospace;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- COMMON UI COMPONENTS --- */

/* Cards & Containers */
.neo-card {
    background: var(--bg-surface-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow-md);
}

/* Form Inputs */
.neo-input, input[type="text"], input[type="password"], input[type="number"], input[type="email"], input[type="url"], input[type="date"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
}

.neo-input:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.neo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.neo-btn-primary {
    background-color: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}
.neo-btn-primary:hover {
    background-color: #1d4ed8 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
    opacity: 1 !important;
}
.neo-btn-primary:active {
    background-color: #1e40af !important;
    color: #ffffff !important;
    transform: scale(0.98);
}

.neo-btn-secondary {
    background-color: var(--bg-surface-elevated) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}
.neo-btn-secondary:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-main) !important;
    border-color: var(--border-focus) !important;
    transform: translateY(-1px);
}

.neo-btn-danger {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}
.neo-btn-danger:hover {
    background-color: #b91c1c !important;
    color: #ffffff !important;
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.35);
    transform: translateY(-1px);
    opacity: 1 !important;
}
.neo-btn-danger:active {
    background-color: #991b1b !important;
    color: #ffffff !important;
    transform: scale(0.98);
}

/* Tables */
.neo-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface-card);
}

.neo-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.neo-table th {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.neo-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.92rem;
}

.neo-table tbody tr:hover {
    background: var(--bg-hover);
}

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

/* Badges */
.neo-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: capitalize;
}

.neo-badge-success {
    background: var(--success-bg);
    color: var(--success-color);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.neo-badge-danger {
    background: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.neo-badge-primary {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Modals */
.neo-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.neo-modal-backdrop.active,
.neo-modal-backdrop.open {
    display: flex;
}

.neo-modal {
    background: var(--bg-surface-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    padding: 28px;
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- SEARCH BAR & TOOLBAR COMPONENT --- */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-box-wrapper {
    position: relative;
    max-width: 420px;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-box-wrapper .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    z-index: 2;
    transition: color 0.15s ease;
}

.search-box-wrapper input.search-input,
.search-box-wrapper input#search,
.search-box-wrapper input#searchInput,
.search-box-wrapper input#userSearch,
.search-box-wrapper input[type="text"] {
    width: 100% !important;
    height: 44px !important;
    padding-left: 44px !important;
    padding-right: 38px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-radius: 10px !important;
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-surface-elevated) !important;
    color: var(--text-main) !important;
    font-size: 0.92rem !important;
    font-weight: 500 !important;
    outline: none !important;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease !important;
}

.search-box-wrapper input.search-input::placeholder,
.search-box-wrapper input#search::placeholder,
.search-box-wrapper input#searchInput::placeholder,
.search-box-wrapper input#userSearch::placeholder,
.search-box-wrapper input[type="text"]::placeholder {
    color: var(--text-muted) !important;
    font-size: 0.88rem !important;
    opacity: 0.85;
}

.search-box-wrapper input.search-input:focus,
.search-box-wrapper input#search:focus,
.search-box-wrapper input#searchInput:focus,
.search-box-wrapper input#userSearch:focus,
.search-box-wrapper input[type="text"]:focus {
    border-color: var(--primary-color) !important;
    background-color: var(--bg-surface) !important;
    box-shadow: 0 0 0 3px var(--primary-light) !important;
}

.search-box-wrapper:focus-within .search-icon {
    color: var(--primary-color) !important;
}

.search-box-wrapper .search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0;
    z-index: 2;
    transition: all 0.15s ease;
}

.search-box-wrapper .search-clear-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

/* --- RESPONSIVE MOBILE UTILITIES --- */
@media (max-width: 768px) {
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .search-box-wrapper {
        max-width: 100% !important;
        width: 100% !important;
    }

    .neo-card, .table-container-card {
        padding: 16px 12px !important;
        border-radius: 12px !important;
    }
}
