/* ============================================================
   Tech Shop Manager — Design System
   Bootstrap 5 is loaded first; this file layers a cohesive,
   modern admin-panel look on top of it. Works LTR and RTL.
   ============================================================ */

:root {
    /* Brand palette */
    --brand:        #4f46e5;   /* indigo */
    --brand-dark:   #4338ca;
    --brand-light:  #eef2ff;
    --accent:       #06b6d4;   /* cyan accent for highlights */

    /* Neutrals */
    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-300: #cbd5e1;
    --ink-100: #f1f5f9;
    --surface: #ffffff;
    --page-bg: #f5f7fb;

    /* Status colors */
    --success: #16a34a;
    --warning: #d97706;
    --danger:  #dc2626;

    /* Layout */
    --sidebar-width: 264px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }

body {
    background-color: var(--page-bg);
    color: var(--ink-900);
    font-family: 'Segoe UI', system-ui, -apple-system, Tahoma, Arial, sans-serif;
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
}

/* Arabic-script languages render noticeably better with a taller line-height. */
[dir="rtl"] body {
    font-family: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
    line-height: 1.9;
}

a { text-decoration: none; }

/* ============================================================
   Layout shell
   ============================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, #111827 0%, #1e1b3a 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem 1.5rem;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    padding: 1rem 0.85rem 0.35rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #cbd5e1;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.85;
}

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

.sidebar .nav-link.active {
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.sidebar .nav-link.active i { opacity: 1; }

.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.page-heading {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid #e5e7eb;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-700);
}

.btn-topbar {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-700);
}

.btn-topbar:hover { background: var(--ink-100); }

.avatar-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.page-body {
    padding: 1.5rem;
    flex-grow: 1;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    border: 1px solid #eef0f4;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid #eef0f4;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.9rem 1.1rem;
    border-top-left-radius: var(--radius-md) !important;
    border-top-right-radius: var(--radius-md) !important;
}

/* ---- KPI cards ---- */
.kpi-card {
    border-radius: var(--radius-md);
    border: 1px solid #eef0f4;
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.25rem;
    position: relative;
    overflow: hidden;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-500);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
}

.kpi-card .kpi-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--ink-900);
    line-height: 1.2;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    position: absolute;
    top: 1.1rem;
    inset-inline-end: 1.1rem;
}

.kpi-icon.bg-brand   { background: var(--brand-light); color: var(--brand); }
.kpi-icon.bg-success { background: #dcfce7; color: var(--success); }
.kpi-icon.bg-warning { background: #fef3c7; color: var(--warning); }
.kpi-icon.bg-danger  { background: #fee2e2; color: var(--danger); }

/* ============================================================
   Tables
   ============================================================ */
.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table thead th {
    background: var(--ink-100);
    color: var(--ink-500);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: none;
    padding: 0.7rem 0.9rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.7rem 0.9rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f7;
}

.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--brand-light); }

/* ============================================================
   Buttons
   ============================================================ */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 0.875rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { border-radius: 7px; }

/* ============================================================
   Forms
   ============================================================ */
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--ink-700); }
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid #dfe3e9;
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

/* ============================================================
   Badges
   ============================================================ */
.badge { font-weight: 600; padding: 0.4em 0.7em; border-radius: 999px; font-size: 0.72rem; }
.badge-low-stock { background-color: #fee2e2; color: #b91c1c; }

/* ============================================================
   Login page
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #6366f1 0%, #1e1b3a 55%, #0f172a 100%);
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
    padding: 2.25rem 2rem !important;
}

.login-card .brand-icon-lg {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--brand-light);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.22s ease-in-out;
        box-shadow: var(--shadow-lg);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.show { transform: translateX(0); }

    .page-body { padding: 1rem; }
    .page-heading { font-size: 1rem; }
}

@media (min-width: 769px) {
    #sidebarToggle { display: none; }
}

/* ============================================================
   Dark mode — toggled via a button in the topbar, saved in
   localStorage as 'techshop-theme'.
   ============================================================ */
[data-theme="dark"] {
    --ink-900: #f1f5f9;
    --ink-700: #cbd5e1;
    --ink-500: #94a3b8;
    --ink-300: #475569;
    --ink-100: #1e293b;
    --surface: #1e293b;
    --page-bg: #0f172a;
    --brand-light: #312e81;
}

[data-theme="dark"] body { background-color: var(--page-bg); color: var(--ink-900); }
[data-theme="dark"] .sidebar { background: #0b1120; border-color: #1e293b; }
[data-theme="dark"] .topbar { background: var(--surface); border-color: #334155; }
[data-theme="dark"] .card,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .login-card { background: var(--surface); border-color: #334155; color: var(--ink-900); }
[data-theme="dark"] .table { color: var(--ink-900); }
[data-theme="dark"] .table > :not(caption) > * > * { background-color: transparent; color: var(--ink-900); border-color: #334155; }
[data-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: rgba(255,255,255,0.04); }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background-color: #0f172a; border-color: #334155; color: var(--ink-900); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus { background-color: #0f172a; color: var(--ink-900); }
[data-theme="dark"] .text-muted { color: var(--ink-500) !important; }
[data-theme="dark"] .card-header { background-color: rgba(255,255,255,0.02); border-color: #334155; }
[data-theme="dark"] .app-credit { color: var(--ink-500); }
[data-theme="dark"] hr { border-color: #334155; }

.theme-toggle-btn {
    border: 1px solid var(--ink-300);
    background: transparent;
    color: var(--ink-700);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, transform 0.15s ease;
}
.theme-toggle-btn:hover { background-color: var(--brand-light); transform: rotate(15deg); }

/* ============================================================
   Micro-interactions — smoother hover/focus feedback throughout
   ============================================================ */
.card, .kpi-card, .btn, .nav-link, .table-hover > tbody > tr {
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: scale(0.97); }
.card { animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Empty states — friendlier than a bare "No records found" row
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-500);
}
.empty-state i {
    font-size: 2.5rem;
    color: var(--ink-300);
    margin-bottom: 0.75rem;
    display: block;
}
