/* ═══════════════════════════════════════════
   BuhReport — Premium Dashboard CSS
   ═══════════════════════════════════════════ */

:root {
    /* Color palette – deep navy & vibrant accent */
    --bg-dark: #0f1225;
    --bg-surface: #161a35;
    --bg-card: rgba(30, 35, 70, 0.65);
    --bg-card-hover: rgba(40, 48, 90, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.15);

    --accent: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.35);
    --accent-light: #a29bfe;
    --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);

    --success: #00cec9;
    --danger: #ff6b6b;
    --warning: #feca57;

    --text-primary: #eef0ff;
    --text-secondary: #8892b0;
    --text-muted: #5a6380;

    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 240px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

body {
    display: flex;
}

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

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 28px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 24px;
}

.brand-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:hover {
    background: rgba(108, 92, 231, 0.1);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.nav-icon { font-size: 18px; }

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 28px 36px;
}

.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.top-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Glass Card ─── */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 28px;
    transition: var(--transition);
}

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

/* ─── Tabs ─── */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* ─── Report Card ─── */
.report-card {
    max-width: 520px;
}

.report-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

/* ─── Form Elements ─── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-field {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: rgba(15, 18, 37, 0.6);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.textarea-field {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-icon {
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-download {
    margin-top: 8px;
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 15px;
}

.report-status {
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    min-height: 20px;
}

.report-status.error {
    color: var(--danger);
}

.report-status.success {
    color: var(--success);
}

/* ─── Corners Toolbar ─── */
.corners-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Toggle Switch */
.toggle-history {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.toggle-history input { display: none; }

.toggle-slider {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: var(--transition);
}

.toggle-history input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-history input:checked + .toggle-slider::after {
    left: 21px;
    background: #fff;
}

/* ─── Table ─── */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-glass);
}

.data-table td {
    padding: 14px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: rgba(108, 92, 231, 0.06);
}

.data-table tbody tr.archived {
    opacity: 0.4;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-active {
    background: rgba(0, 206, 201, 0.15);
    color: var(--success);
}

.badge-archived {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger);
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.btn-edit {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit:hover {
    background: rgba(108, 92, 231, 0.3);
}

.btn-delete {
    background: rgba(255, 107, 107, 0.12);
    color: var(--danger);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-delete:hover {
    background: rgba(255, 107, 107, 0.25);
}

/* ─── Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

/* ─── Loading spinner ─── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ─── Utility ─── */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; }
.gap-md       { gap: 12px; }
.w-100        { width: 100%; }
.text-right   { text-align: right; }

/* ─── Toggle switch (used in corners) ─── */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: rgba(255,255,255,0.1); border-radius: 11px; transition: var(--transition);
}
.toggle-switch .slider::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--text-secondary); transition: var(--transition);
}
.toggle-switch input:checked + .slider { background: var(--accent); }
.toggle-switch input:checked + .slider::after { left: 21px; background: #fff; }

/* ─── Analytics toolbar ─── */
.analytics-toolbar {
    margin-bottom: 24px;
}
.analytics-toolbar .form-row.compact {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}
.analytics-toolbar .form-group {
    margin-bottom: 0;
    min-width: 140px;
}
.quick-ranges {
    display: flex;
    gap: 6px;
}
.btn-ghost {
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.btn-ghost:hover, .btn-ghost.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.corner-detail-col {
    width: 1%;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
}
#corner-revenue-table .corner-detail-btn {
    padding: 4px 8px;
    min-width: auto;
    line-height: 1;
}

/* ─── KPI Cards ─── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.kpi-card {
    position: relative;
    border-radius: var(--radius);
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    transition: var(--transition);
}

.kpi-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.12;
    border-radius: var(--radius);
    transition: opacity 0.3s;
}
.kpi-card:hover::before { opacity: 0.2; }

.kpi-orders  { background: rgba(108, 92, 231, 0.12); }
.kpi-orders::before  { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }

.kpi-revenue { background: rgba(0, 206, 201, 0.12); }
.kpi-revenue::before { background: linear-gradient(135deg, #00cec9, #55efc4); }

.kpi-avg     { background: rgba(253, 203, 110, 0.12); }
.kpi-avg::before     { background: linear-gradient(135deg, #fdcb6e, #ffeaa7); }

.kpi-corners { background: rgba(162, 155, 254, 0.12); }
.kpi-corners::before { background: linear-gradient(135deg, #a29bfe, #dfe6e9); }

.kpi-icon {
    font-size: 32px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
}

.kpi-body { position: relative; z-index: 1; }

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    line-height: 1.1;
}

.kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ─── Chart ─── */
.chart-section {
    margin-bottom: 24px;
}
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.chart-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}
.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ─── Section header ─── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Table tfoot ─── */
.data-table tfoot td {
    padding: 12px 14px;
    font-weight: 700;
    border-top: 2px solid var(--border-glass);
    font-size: 14px;
    color: var(--text-primary);
}

/* ─── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pagination .page-btn {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.pagination .page-btn:hover { background: rgba(108,92,231,0.15); color: var(--text-primary); }
.pagination .page-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.pagination .page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.pagination .page-info {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 8px;
}

/* ─── Revenue bar in table ─── */
.revenue-bar-cell {
    position: relative;
}
.revenue-bar-bg {
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    background: rgba(108, 92, 231, 0.12);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ─── Cards margin ─── */
.card.glass-card + .card.glass-card {
    margin-top: 20px;
}

/* ─── Loading overlay for analytics ─── */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15,18,37,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 10;
}

/* ─── User badge in header ─── */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-size: 13px;
}
.user-name { color: var(--text-primary); font-weight: 600; }
.btn-link {
    background: none;
    border: none;
    color: var(--accent-light);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 4px;
}
.btn-link:hover { color: var(--text-primary); text-decoration: underline; }

/* ─── Login overlay ─── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 25, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.login-overlay[hidden] { display: none; }
.login-card {
    width: min(380px, 100%);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-card h2 {
    margin: 0 0 4px;
    font-size: 20px;
    text-align: center;
}
.login-error {
    color: var(--danger);
    font-size: 13px;
    background: rgba(255, 107, 107, 0.08);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 107, 107, 0.25);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        padding: 16px 8px;
    }
    .brand-text, .nav-btn span:last-child { display: none; }
    .main-content { padding: 20px 16px; }
    .modal { width: 95%; margin: 0 10px; }
    .form-row { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .analytics-toolbar .form-row.compact { flex-direction: column; }
    .quick-ranges { flex-wrap: wrap; }
}
