/* ========================================
   SmartStore Mass Upload — Design System
   Based on K&G Financial Architect
   ======================================== */

/* ── Design Tokens ── */
:root {
    /* Primary palette */
    --primary: #000666;
    --primary-hover: #1a237e;
    --primary-light: #4c56af;
    --primary-muted: rgba(0, 6, 102, 0.10);
    --primary-subtle: rgba(0, 6, 102, 0.05);

    /* Secondary (Mint) */
    --secondary: #006a62;
    --secondary-light: #66d9cc;
    --secondary-muted: rgba(0, 106, 98, 0.10);
    --secondary-container: #81f3e5;

    /* Semantic */
    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.10);
    --warning: #f59e0b;
    --warning-muted: rgba(245, 158, 11, 0.10);
    --danger: #ef4444;
    --danger-muted: rgba(239, 68, 68, 0.10);

    /* Neutrals — Tonal Layering */
    --surface: #f8f9fa;
    --surface-container-low: #f3f4f5;
    --surface-container: #edeeef;
    --surface-container-high: #e7e8e9;
    --surface-container-highest: #e1e3e4;
    --surface-container-lowest: #ffffff;
    --on-surface: #191c1d;
    --on-surface-variant: #454652;

    /* Grays */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Sidebar dark */
    --sidebar-bg: #111827;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active: rgba(79,110,247,0.15);
    --sidebar-text: rgba(255,255,255,0.55);
    --sidebar-text-active: #fff;
    --sidebar-border: rgba(255,255,255,0.06);

    /* Layout */
    --bg: var(--surface);
    --border: #e2e8f0;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows — Ambient (blue-tinted per DESIGN.md) */
    --shadow-xs: 0 1px 2px rgba(0,7,103,0.04);
    --shadow-sm: 0 1px 3px rgba(0,7,103,0.06), 0 1px 2px rgba(0,7,103,0.04);
    --shadow-md: 0 4px 8px rgba(0,7,103,0.06), 0 2px 4px rgba(0,7,103,0.04);
    --shadow-lg: 0 12px 40px rgba(0,7,103,0.06);

    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .font-headline {
    font-family: 'Manrope', 'Inter', sans-serif;
}

/* ── Layout Shell ── */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════ */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.brand {
    height: 64px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0,6,102,0.3);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-family: 'Manrope', sans-serif;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-500);
}

.menu {
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
}

.menu-label {
    padding: 18px 20px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
}

.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    margin: 1px 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.menu a i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.menu a:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.85);
}

.menu a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.menu a.active i {
    color: #8690ee;
}

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

.sidebar-footer .status {
    font-size: 11px;
    font-weight: 500;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 5px;
}

.sidebar-footer .status i {
    font-size: 8px;
    color: var(--success);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease;
}

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

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px;
    border-radius: 6px;
    transition: background var(--transition-fast);
}

.hamburger-btn:hover {
    background: var(--gray-100);
}

/* ════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Top Bar ── */
.topbar {
    height: 56px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 50;
    box-shadow: var(--shadow-xs);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-family: 'Manrope', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Page Body ── */
.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ════════════════════════════════════════
   PAGE VIEW CONTAINERS
   ════════════════════════════════════════ */
.page-view {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.page-view.active {
    display: flex;
}

/* ════════════════════════════════════════
   PANELS (Cards) — No-Line Rule
   ════════════════════════════════════════ */
.panel {
    background: var(--surface-container-lowest);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-container-low);
}

.panel-header h2 {
    font-family: 'Manrope', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h2 i {
    font-size: 18px;
    color: var(--primary-light);
}

.panel-body {
    padding: 20px;
}

.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════ */
.fg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.fg > label:first-child {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.fg > label .required {
    color: var(--danger);
    margin-left: 2px;
}

.fg input,
.fg select,
.fg textarea {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: all var(--transition-fast);
    background: var(--surface-container-lowest);
    color: var(--gray-800);
    width: 100%;
    font-family: inherit;
}

.fg textarea {
    height: auto;
    padding: 8px 10px;
    resize: vertical;
    min-height: 36px;
}

.fg input::placeholder,
.fg textarea::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

.fg input:focus,
.fg select:focus,
.fg textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
    background: var(--surface-container-lowest);
}

.fg input:disabled,
.fg select:disabled {
    background: var(--surface-container-high);
    color: var(--gray-500);
    cursor: not-allowed;
}

.fg-full {
    grid-column: 1 / -1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.form-help {
    font-size: 11px;
    color: var(--gray-400);
    line-height: 1.3;
    margin-top: 2px;
}

/* ════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0,6,102,0.2);
    white-space: nowrap;
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(0,6,102,0.3);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-primary i {
    font-size: 16px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--surface-container-high);
    color: var(--on-surface);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--surface-container-highest);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-container-lowest);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-outline:hover {
    background: var(--surface-container-low);
    border-color: var(--gray-300);
}

.btn-outline i {
    font-size: 14px;
}

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

.btn-outline-success:hover {
    background: var(--secondary-muted);
}

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

.btn-outline-danger:hover {
    background: var(--danger-muted);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--gray-500);
    transition: all var(--transition-fast);
}

.btn-ghost:hover {
    background: var(--surface-container-high);
    color: var(--on-surface);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.btn-lg {
    padding: 10px 24px;
    font-size: 14px;
}

/* ════════════════════════════════════════
   DATA TABLE
   ════════════════════════════════════════ */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.data-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: var(--surface-container-low);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

.data-table thead th.sortable {
    cursor: pointer;
    transition: color var(--transition-fast);
}

.data-table thead th.sortable:hover {
    color: var(--primary);
}

.data-table thead th.sortable i {
    font-size: 12px;
    opacity: 0.4;
    margin-left: 2px;
}

.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--surface-container-high);
    color: var(--gray-700);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--primary-subtle);
}

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

.col-check {
    width: 40px;
    text-align: center;
}

.col-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

.col-actions {
    white-space: nowrap;
}

.col-actions button {
    padding: 4px 6px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--gray-500);
    font-size: 16px;
    transition: all var(--transition-fast);
}

.col-actions button:hover {
    background: var(--surface-container-high);
    color: var(--primary);
}

.col-actions button.delete:hover {
    color: var(--danger);
}

/* ════════════════════════════════════════
   BADGES
   ════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

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

.badge-warning {
    background: var(--warning-muted);
    color: #b45309;
}

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

.badge-primary {
    background: var(--primary-muted);
    color: var(--primary);
}

.badge-secondary {
    background: var(--secondary-muted);
    color: var(--secondary);
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-500);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-container-lowest);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0.85;
    backdrop-filter: blur(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface-container-low);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h2 {
    font-family: 'Manrope', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--on-surface);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    background: var(--surface-container-low);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: all var(--transition-fast);
}

.btn-close:hover {
    background: var(--surface-container-high);
    color: var(--on-surface);
}

/* ════════════════════════════════════════
   TOAST
   ════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease forwards 2.7s;
    min-width: 280px;
    background: var(--surface-container-lowest);
    color: var(--on-surface);
}

.toast i {
    font-size: 18px;
    flex-shrink: 0;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--primary-light); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.pagination button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination button:hover {
    background: var(--surface-container-high);
}

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

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

/* ════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-400);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 12px;
}

/* ════════════════════════════════════════
   LOGIN OVERLAY
   ════════════════════════════════════════ */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: linear-gradient(135deg, #111827 0%, #1e293b 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--surface-container-lowest);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 8px;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.06) !important;
}

/* ════════════════════════════════════════
   UTILITY
   ════════════════════════════════════════ */
.hidden {
    display: none !important;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: #b45309; }
.text-muted { color: var(--gray-500); }

.font-mono {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 100;
    }

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

    .hamburger-btn {
        display: flex;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-body {
        padding: 16px;
    }

    .form-grid,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header-actions {
        flex-wrap: wrap;
    }
}
