/* ============================================================
   StockPro — Bootstrap 5 Override & Theme Layer
   Dark / Light switchable via [data-bs-theme]
   ============================================================ */

/* ── Google Fonts ───────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,400&display=swap');

/* ── CSS Custom Properties ──────────────────── */
:root,
[data-bs-theme="dark"] {
    --sp-accent:        #f59e0b;
    --sp-accent-dim:    #d97706;
    --sp-accent-glow:   rgba(245,158,11,0.15);
    --sp-sidebar-bg:    #13161e;
    --sp-sidebar-w:     240px;
    --sp-topbar-h:      60px;
    --sp-brand-icon-bg: #f59e0b;
    --sp-brand-icon-c:  #000;
    --sp-nav-active-bg: rgba(245,158,11,0.12);
    --sp-card-hover-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

[data-bs-theme="light"] {
    --sp-accent:        #d97706;
    --sp-accent-dim:    #b45309;
    --sp-accent-glow:   rgba(217,119,6,0.10);
    --sp-sidebar-bg:    #1e2430;
    --sp-brand-icon-bg: #d97706;
    --sp-brand-icon-c:  #fff;
    --sp-nav-active-bg: rgba(217,119,6,0.15);
    --sp-card-hover-shadow: 0 8px 30px rgba(0,0,0,0.10);
}

/* ── Base ───────────────────────────────────── */
body {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

h1,h2,h3,h4,h5,h6,
.page-title,
.card-title,
.modal-title,
.brand-name {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
}

/* ── Sidebar ────────────────────────────────── */
.sp-sidebar {
    width: var(--sp-sidebar-w);
    min-height: 100vh;
    background-color: var(--sp-sidebar-bg) !important;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sp-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sp-brand-icon {
    width: 38px; height: 38px;
    background: var(--sp-brand-icon-bg);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--sp-brand-icon-c);
    font-size: 16px;
    flex-shrink: 0;
}

.sp-brand-name {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    display: block;
    letter-spacing: 0.05em;
    line-height: 1.1;
}

.sp-brand-tag {
    font-size: 9px;
    color: rgba(255,255,255,0.4);
    display: block;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sp-nav { flex: 1; padding: 10px 0; }

.sp-nav-section {
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    padding: 10px 20px 4px;
    font-weight: 700;
}

.sp-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}

.sp-nav-link i { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }

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

.sp-nav-link.active {
    background: var(--sp-nav-active-bg);
    color: var(--sp-accent);
    border-left-color: var(--sp-accent);
    font-weight: 500;
}

.sp-sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

/* Theme toggle in sidebar footer */
.sp-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sp-theme-label {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-company-info {
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Main Wrapper ───────────────────────────── */
.sp-wrapper {
    margin-left: var(--sp-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ── Topbar ─────────────────────────────────── */
.sp-topbar {
    height: var(--sp-topbar-h);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    transition: background-color 0.25s;
}

.sp-topbar-title {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 15px;
    flex: 1;
    letter-spacing: 0.03em;
}

/* Topbar theme button */
.sp-theme-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    position: relative;
}

.sp-theme-btn:hover { transform: rotate(20deg); }

.sp-theme-btn .icon-sun,
.sp-theme-btn .icon-moon {
    position: absolute;
    transition: opacity 0.3s, transform 0.3s;
}

[data-bs-theme="dark"]  .sp-theme-btn .icon-sun  { opacity: 1; transform: scale(1); }
[data-bs-theme="dark"]  .sp-theme-btn .icon-moon { opacity: 0; transform: scale(0); }
[data-bs-theme="light"] .sp-theme-btn .icon-sun  { opacity: 0; transform: scale(0); }
[data-bs-theme="light"] .sp-theme-btn .icon-moon { opacity: 1; transform: scale(1); }

.sp-user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--sp-accent);
    color: #000;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Main Content ───────────────────────────── */
.sp-content { padding: 24px; flex: 1; }

/* ── Stat Cards ─────────────────────────────── */
.sp-stat {
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: default;
}

.sp-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--sp-card-hover-shadow) !important;
}

.sp-stat::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 70px; height: 70px;
    background: var(--sp-glow, var(--sp-accent-glow));
    border-radius: 0 12px 0 70px;
    pointer-events: none;
}

.sp-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    opacity: 0.6;
    margin-bottom: 6px;
}

.sp-stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
}

.sp-stat-sub { font-size: 11px; opacity: 0.5; margin-top: 4px; }

.sp-stat-icon {
    position: absolute;
    top: 16px; right: 16px;
    font-size: 20px;
    opacity: 0.25;
}

/* ── Tables ─────────────────────────────────── */
.table th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    white-space: nowrap;
}

.table td { vertical-align: middle; font-size: 13px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges (accent) ────────────────────────── */
.badge.bg-accent { background: var(--sp-accent) !important; color: #000; }
.badge.bg-accent-soft { background: var(--sp-accent-glow) !important; color: var(--sp-accent); border: 1px solid var(--sp-accent); }

/* ── Invoice Items Builder ──────────────────── */
.item-table th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.item-table td { padding: 6px 8px; }
.item-table .form-control,
.item-table .form-select { font-size: 12px; padding: 5px 8px; }

/* ── Product Chip ───────────────────────────── */
.prod-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    text-decoration: none;
    border: 1px solid;
    transition: all 0.15s;
    white-space: nowrap;
}

.prod-chip:hover { opacity: 0.85; transform: translateY(-1px); }

/* ── Statement Rows ─────────────────────────── */
.stmt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-size: 13px;
    transition: background 0.1s;
}

[data-bs-theme="dark"] .stmt-row {
    border-bottom-color: rgba(255,255,255,0.06);
}

.stmt-row:hover { background: rgba(0,0,0,0.04); }

[data-bs-theme="dark"] .stmt-row:hover { background: rgba(255,255,255,0.04); }

.stmt-row.total-row {
    font-weight: 700;
    border-top: 2px solid rgba(0,0,0,0.1);
    border-bottom: none;
}

.stmt-row.grand-row {
    background: var(--sp-accent-glow) !important;
    color: var(--sp-accent);
    font-weight: 700;
    font-size: 14px;
    border-top: 2px solid var(--sp-accent);
    border-radius: 6px;
    margin: 8px 12px;
}

/* ── Progress bar accent ────────────────────── */
.progress-bar.bg-accent { background: var(--sp-accent) !important; }

/* ── Totals summary box ─────────────────────── */
.totals-box .row-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-size: 13px;
    gap: 10px;
}

[data-bs-theme="dark"] .totals-box .row-item {
    border-bottom-color: rgba(255,255,255,0.06);
}

.totals-box .row-item:last-child { border-bottom: none; }
.totals-box .row-item.grand { font-weight: 700; font-size: 15px; color: var(--sp-accent); padding-top: 10px; }

/* ── Nav tabs (custom accent) ───────────────── */
.sp-tabs .nav-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--bs-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 18px;
    transition: all 0.15s;
}

.sp-tabs .nav-link.active,
.sp-tabs .nav-link:hover {
    color: var(--sp-accent);
    border-bottom-color: var(--sp-accent);
    background: transparent;
}

/* ── Modal animation ────────────────────────── */
.modal.fade .modal-dialog { transition: transform 0.2s ease, opacity 0.2s ease; }
.modal.fade:not(.show) .modal-dialog { transform: scale(0.96) translateY(10px); opacity: 0; }

/* ── Card hover lift ────────────────────────── */
.card-lift { transition: transform 0.15s, box-shadow 0.15s; }
.card-lift:hover { transform: translateY(-2px); box-shadow: var(--sp-card-hover-shadow) !important; }

/* ── Sidebar overlay (mobile) ───────────────── */
.sp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1039;
    backdrop-filter: blur(2px);
}
.sp-overlay.show { display: block; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 991.98px) {
    .sp-sidebar { transform: translateX(-100%); box-shadow: none; }
    .sp-sidebar.show { transform: translateX(0); box-shadow: 4px 0 40px rgba(0,0,0,0.4); }
    .sp-wrapper { margin-left: 0; }
    .sp-mob-toggle { display: flex !important; }
}

@media (min-width: 992px) {
    .sp-mob-toggle { display: none !important; }
}

@media (max-width: 575.98px) {
    .sp-content { padding: 14px; }
    .sp-topbar  { padding: 0 14px; }
    .hide-xs    { display: none !important; }
}

/* ── Accent utilities ───────────────────────── */
.text-accent  { color: var(--sp-accent)  !important; }
.border-accent { border-color: var(--sp-accent) !important; }
.bg-accent-glow { background: var(--sp-accent-glow) !important; }

/* ── Print ──────────────────────────────────── */
@media print {
    .sp-sidebar, .sp-topbar, .sp-overlay,
    .btn, .filter-bar, .modal { display: none !important; }
    .sp-wrapper { margin-left: 0 !important; }
}
