/* ═══════════════════════════════════════════════════════════
   SmartInvoice — Premium Design System
   Dark/Light Adaptive Theme with Glassmorphic Accents
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables (Light Theme) ────────────────────────── */
:root {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fc;
    --bg-input: #f4f5f9;
    --bg-navbar: #ffffff;
    --navbar-text: #5a6078;
    --navbar-text-hover: #1a1d2e;
    --navbar-hover-bg: rgba(0, 0, 0, 0.05);
    --navbar-border: #e5e7ef;
    --bg-glass: rgba(255, 255, 255, 0.7);

    --text-primary: #1a1d2e;
    --text-secondary: #5a6078;
    --text-muted: #8b90a5;
    --text-inverse: #ffffff;

    --border-color: #e5e7ef;
    --border-light: #eef0f6;

    --accent: #C8540A;
    --accent-light: #f0ddd0;
    --accent-hover: #a84508;
    --success: #0d9f6e;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(200, 84, 10, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Dark Theme ─────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-primary: #0f1119;
    --bg-secondary: #181b27;
    --bg-tertiary: #1e2132;
    --bg-card: #1a1d2e;
    --bg-card-hover: #222640;
    --bg-input: #1e2132;
    --bg-glass: rgba(24, 27, 39, 0.8);

    --text-primary: #e8eaf0;
    --text-secondary: #a0a4b8;
    --text-muted: #6b7089;
    --text-inverse: #0f1119;

    --border-color: #2a2e42;
    --border-light: #232738;

    --accent-light: #3d2510;
    --success-light: #0d2e1f;
    --danger-light: #2e1111;
    --warning-light: #2e2510;
    --info-light: #1a2540;

    --bg-navbar: #141722;
    --navbar-text: #8b90a5;
    --navbar-text-hover: #e8eaf0;
    --navbar-hover-bg: rgba(255, 255, 255, 0.08);
    --navbar-border: #2a2e42;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(200, 84, 10, 0.2);
}

/* ── Base Reset & Typography ────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Premium Card System ────────────────────────────────── */
.si-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.si-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.si-card-static {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ── Glassmorphic Card ──────────────────────────────────── */
.si-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
}

/* ── Stat Cards ─────────────────────────────────────────── */
.si-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.si-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--warning));
    opacity: 0;
    transition: var(--transition);
}

.si-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.si-stat:hover::before {
    opacity: 1;
}

/* ── Premium Tables ─────────────────────────────────────── */
.si-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .si-table thead th,
    .si-table tbody td {
        padding: 0.625rem 0.75rem;
        font-size: 0.775rem;
    }
    .si-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .si-stat { padding: 1rem; }
    .si-stat p { font-size: 1.25rem !important; }
    main { padding-left: 1rem !important; padding-right: 1rem !important; }
}

.si-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.si-table thead {
    background: var(--bg-tertiary);
}

.si-table thead th {
    padding: 0.875rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.si-table tbody tr {
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

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

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

.si-table tbody td {
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

/* ── Premium Inputs ─────────────────────────────────────── */
.si-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: var(--transition);
    outline: none;
}

.si-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200, 84, 10, 0.12);
    background: var(--bg-card);
}

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

.si-input[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
}

.si-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%236b7089' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 2rem;
}

textarea.si-input {
    resize: vertical;
    min-height: 5rem;
}

.si-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

/* ── Buttons ────────────────────────────────────────────── */
.si-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.si-btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.si-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.si-btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.si-btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.si-btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.si-btn-ghost {
    background: transparent;
    color: var(--accent);
    padding: 0.375rem 0.75rem;
}

.si-btn-ghost:hover {
    background: var(--accent-light);
}

.si-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.775rem;
}

.si-btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

/* ── Badges / Status Chips ──────────────────────────────── */
.si-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 50px;
    letter-spacing: 0.02em;
}

.si-badge-success { background: var(--success-light); color: var(--success); }
.si-badge-danger  { background: var(--danger-light);  color: var(--danger); }
.si-badge-warning { background: var(--warning-light); color: var(--warning); }
.si-badge-info    { background: var(--info-light);    color: var(--info); }
.si-badge-muted   { background: var(--bg-tertiary);   color: var(--text-muted); }

/* ── Navbar ─────────────────────────────────────────────── */
.si-nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--navbar-text);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.si-nav-link:hover {
    color: var(--navbar-text-hover);
    background: var(--navbar-hover-bg);
}

.si-navbar {
    background: var(--bg-navbar);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 64px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--navbar-border);
    box-shadow: var(--shadow-sm);
    transition: background 0.4s ease, border-color 0.4s ease;
}

.si-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.25rem;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: var(--transition-fast);
    z-index: 60;
}

.group:hover .si-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.si-dropdown a {
    display: block;
    padding: 0.625rem 1rem;
    font-size: 0.825rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.si-dropdown a:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.si-dropdown a:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.si-dropdown a:last-child  { border-radius: 0 0 var(--radius-md) var(--radius-md); }

/* ── Page Header ────────────────────────────────────────── */
.si-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.si-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.si-page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Section Header ─────────────────────────────────────── */
.si-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1.25rem;
}

/* ── Search Bar ─────────────────────────────────────────── */
.si-search {
    position: relative;
}

.si-search input {
    padding-left: 2.75rem;
}

.si-search svg {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Product Dropdown (Sale/Purchase forms) ─────────────── */
.product-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    position: absolute;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
}

.product-dropdown::-webkit-scrollbar { width: 5px; }
.product-dropdown::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* ── Flash Messages ─────────────────────────────────────── */
.si-flash {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    animation: siSlideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.si-flash-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.si-flash-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

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

/* ── Pagination ─────────────────────────────────────────── */
.si-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 1.5rem;
}

.si-pagination a {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: var(--transition-fast);
    text-decoration: none;
}

.si-pagination a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.si-pagination a.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Theme Toggle ───────────────────────────────────────── */
.si-theme-toggle {
    width: 44px;
    height: 24px;
    border-radius: 50px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.si-theme-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fbbf24;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .si-theme-toggle::after {
    transform: translateX(20px);
    background: #818cf8;
}

/* Theme icon visibility */
.si-theme-icon-sun { opacity: 1; }
.si-theme-icon-moon { opacity: 0.3; }
[data-theme="dark"] .si-theme-icon-sun { opacity: 0.3; }
[data-theme="dark"] .si-theme-icon-moon { opacity: 1; }

/* ── Empty State ────────────────────────────────────────── */
.si-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.si-empty svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    opacity: 0.4;
}

/* ── Print ──────────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    body { background: white !important; color: #000 !important; }
    .si-navbar { display: none !important; }
    .shadow-lg { box-shadow: none !important; }
}

/* ── Mobile Menu ─────────────────────────────────────────── */
.si-mobile-menu {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 49;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.si-mobile-menu.si-mobile-open {
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}

.si-mobile-link {
    display: block;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.si-mobile-link:hover {
    color: var(--accent);
    padding-left: 0.5rem;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.si-animate-in {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.si-animate-in:nth-child(2) { animation-delay: 0.05s; }
.si-animate-in:nth-child(3) { animation-delay: 0.1s; }
.si-animate-in:nth-child(4) { animation-delay: 0.15s; }
