/* ============================================
   Shakti Jewels — Design System (Light)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Fraunces:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* ── Design Tokens ── */
:root {
    /* Surfaces — warm cream tones (hue 45 = warm) */
    --surface-0: oklch(98.5% 0.008 70);
    --surface-1: oklch(100% 0 0);
    --surface-2: oklch(96% 0.008 70);
    --surface-3: oklch(93% 0.01 70);
    --surface-4: oklch(90% 0.01 70);

    /* Text — warm-tinted darks */
    --text-primary: oklch(20% 0.015 50);
    --text-secondary: oklch(40% 0.01 50);
    --text-muted: oklch(55% 0.01 50);
    --text-heading: oklch(15% 0.02 50);

    /* Primary accent — warm gold */
    --gold: oklch(60% 0.14 55);
    --gold-subtle: oklch(60% 0.14 55 / 0.08);
    --gold-hover: oklch(55% 0.15 55);
    --gold-text: oklch(45% 0.12 55);

    /* Semantic */
    --emerald: oklch(50% 0.14 160);
    --emerald-subtle: oklch(50% 0.14 160 / 0.08);
    --amber: oklch(60% 0.14 75);
    --amber-subtle: oklch(60% 0.14 75 / 0.08);
    --rose: oklch(55% 0.18 15);
    --rose-subtle: oklch(55% 0.18 15 / 0.08);
    --blue: oklch(55% 0.14 250);
    --blue-subtle: oklch(55% 0.14 250 / 0.06);
    --purple: oklch(50% 0.15 300);
    --purple-subtle: oklch(50% 0.15 300 / 0.06);

    /* Borders */
    --border: oklch(88% 0.008 70);
    --border-input: oklch(82% 0.01 70);
    --border-focus: oklch(60% 0.14 55 / 0.4);

    /* Typography */
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-display: 'Fraunces', Georgia, serif;
    --body-weight: 400;
    --heading-weight: 700;

    /* Type scale — 1.25 major third */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.563rem;
    --text-2xl: 1.953rem;

    /* Spacing */
    --sidebar-width: 240px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-base: 250ms;
}

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

body {
    font-family: var(--font-sans);
    font-weight: var(--body-weight);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-0);
    -webkit-font-smoothing: antialiased;
    font-kerning: normal;
    min-height: 100vh;
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--duration-base) var(--ease-out);
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: var(--gold);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

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

.brand-name {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}

.brand-tagline {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-nav { flex: 1; padding: 0.5rem 0.6rem; overflow-y: auto; }

.nav-section-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0.9rem 0.75rem 0.35rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color var(--duration-fast) ease, background var(--duration-fast) ease;
    position: relative;
    margin-bottom: 1px;
}

.sidebar-nav a:hover { color: var(--text-primary); background: var(--surface-2); }

.sidebar-nav a.active { color: var(--gold-text); background: var(--gold-subtle); }

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: -0.6rem;
    top: 25%; width: 3px; height: 50%;
    background: var(--gold);
    border-radius: 0 2px 2px 0;
}

.nav-icon { width: 18px; height: 18px; opacity: 0.5; flex-shrink: 0; }
.sidebar-nav a.active .nav-icon,
.sidebar-nav a:hover .nav-icon { opacity: 0.8; }

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

.sidebar-footer a {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem;
    color: var(--text-muted); text-decoration: none; font-size: var(--text-sm);
    border-radius: var(--radius-sm); transition: color var(--duration-fast) ease;
}
.sidebar-footer a:hover { color: var(--rose); }

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--surface-1);
    position: sticky; top: 0; z-index: 50;
}

.content-body { flex: 1; padding: 2rem; max-width: 1200px; width: 100%; }

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

.page-header h1 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--heading-weight);
    color: var(--text-heading);
}

.page-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Cards ── */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 1rem;
}

.card h3 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.75rem;
}

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.35rem; padding: 0.5rem 1rem; border: none;
    border-radius: var(--radius-sm); cursor: pointer; text-decoration: none;
    font-family: inherit; font-size: var(--text-sm); font-weight: 600;
    transition: transform var(--duration-fast) ease, opacity var(--duration-fast) ease, background var(--duration-fast) ease;
    white-space: nowrap; line-height: 1.4;
}

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

.btn-primary { background: var(--gold); color: white; }
.btn-primary:hover { background: var(--gold-hover); }

.btn-secondary { background: var(--surface-3); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--surface-4); color: var(--text-primary); }

.btn-success { background: var(--emerald-subtle); color: var(--emerald); }
.btn-success:hover { opacity: 0.85; }

.btn-danger { background: var(--rose-subtle); color: var(--rose); }
.btn-danger:hover { opacity: 0.85; }

.btn-lg { padding: 0.7rem 1.5rem; font-size: var(--text-base); border-radius: var(--radius-md); }
.btn-block { width: 100%; }

/* ── Tables ── */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }

th, td { padding: 0.7rem 1rem; text-align: left; }

th {
    font-size: var(--text-xs); font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

td { font-size: var(--text-sm); color: var(--text-primary); border-bottom: 1px solid var(--surface-2); }

tbody tr { transition: background var(--duration-fast) ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block; margin-bottom: 0.3rem;
    font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.55rem 0.75rem;
    background: var(--surface-1); border: 1px solid var(--border-input);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-family: inherit; font-size: var(--text-sm);
    transition: border-color var(--duration-fast) ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-subtle);
}

.form-group input[readonly] { opacity: 0.6; cursor: default; background: var(--surface-2); }

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem;
}

.form-group select option { background: var(--surface-1); color: var(--text-primary); }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.6rem; border-radius: 20px;
    font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em;
}

.badge-draft { background: var(--surface-3); color: var(--text-muted); }
.badge-sent { background: var(--blue-subtle); color: var(--blue); }
.badge-accepted { background: var(--emerald-subtle); color: var(--emerald); }
.badge-rejected { background: var(--rose-subtle); color: var(--rose); }
.badge-paid { background: var(--emerald-subtle); color: var(--emerald); }
.badge-unpaid { background: var(--amber-subtle); color: var(--amber); }

/* ── Flash Messages ── */
.flash {
    padding: 0.75rem 1rem; border-radius: var(--radius-md);
    margin-bottom: 1.25rem; font-size: var(--text-sm); font-weight: 500;
    display: flex; align-items: center; gap: 0.5rem;
    animation: slideDown 300ms var(--ease-out);
}

.flash-success { background: var(--emerald-subtle); color: var(--emerald); }
.flash-error { background: var(--rose-subtle); color: var(--rose); }

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

/* ── Utilities ── */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Info rows (view pages) ── */
.info-row {
    display: flex; gap: 1rem; padding: 0.5rem 0;
    border-bottom: 1px solid var(--surface-2);
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: var(--text-sm); color: var(--text-muted); width: 130px; flex-shrink: 0; font-weight: 500; }
.info-value { font-size: var(--text-sm); color: var(--text-primary); }

/* ── Amount display ── */
.amount-display {
    font-size: var(--text-xl); font-weight: 700;
    color: var(--gold-text); font-variant-numeric: tabular-nums;
}
.amount-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Diamond & Charge item cards ── */
.diamond-card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-left: 3px solid var(--purple); border-radius: var(--radius-md);
    padding: 1rem; margin-bottom: 0.5rem;
}

.charge-card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-left: 3px solid var(--blue); border-radius: var(--radius-md);
    padding: 1rem; margin-bottom: 0.5rem;
}

.diamond-item.card, .charge-item.card {
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 1rem; margin-bottom: 0.5rem;
}

/* ── Alert ── */
.alert-error {
    background: var(--rose-subtle) !important; border: 1px solid oklch(55% 0.18 15 / 0.15) !important;
    color: var(--rose) !important; border-radius: var(--radius-md) !important;
    padding: 1rem !important; margin-bottom: 1rem;
}

/* ── Quick Actions ── */
.quick-action {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 1rem 1.25rem; background: var(--surface-1);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    text-decoration: none; color: var(--text-primary);
    transition: border-color var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.quick-action:hover { border-color: var(--gold); transform: translateY(-2px); }

.quick-action-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--text-secondary);
}

.quick-action-text { font-weight: 600; font-size: var(--text-sm); }
.quick-action-subtext { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Login ── */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--surface-0);
}

.login-card {
    max-width: 380px; width: 90%; background: var(--surface-1);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
}

.login-brand { margin-bottom: 2rem; }

.login-brand-icon {
    width: 44px; height: 44px; background: var(--gold);
    border-radius: var(--radius-md); display: flex; align-items: center;
    justify-content: center; margin-bottom: 1rem; color: white;
}

.login-brand h2 {
    font-family: var(--font-display); font-size: var(--text-lg);
    font-weight: 700; color: var(--text-heading); margin-bottom: 0.2rem;
}

.login-brand p { font-size: var(--text-sm); color: var(--text-muted); }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: oklch(20% 0.01 50 / 0.4); z-index: 1000; }

.modal-content {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 2rem; max-width: 420px; width: 90%;
}

.modal-content h3 { font-size: var(--text-base); font-weight: 600; color: var(--text-heading); margin-bottom: 0.5rem; }
.modal-content p { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: 1rem; }

/* ── Source Estimate Banner ── */
.source-banner {
    background: var(--emerald-subtle); border-radius: var(--radius-md);
    padding: 0.7rem 1rem; margin-bottom: 1.25rem;
    font-size: var(--text-sm); color: var(--emerald);
}
.source-banner a { color: var(--emerald); font-weight: 600; }

/* ── New Customer Panel ── */
.new-customer-panel {
    margin-top: 1rem; padding: 1.25rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

/* ── Empty State ── */
.empty-state { padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-state p { font-size: var(--text-sm); margin-bottom: 0.5rem; }
.empty-state a { color: var(--gold-text); text-decoration: none; font-weight: 500; }
.empty-state a:hover { text-decoration: underline; }

/* ── Footer ── */
.app-footer {
    padding: 1.5rem 2rem; color: var(--text-muted);
    font-size: var(--text-xs); border-top: 1px solid var(--border); margin-top: 2rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .content-body { padding: 1.25rem; }
    .mobile-menu-btn { display: flex !important; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 769px) { .mobile-menu-btn { display: none !important; } }

.mobile-menu-btn {
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-secondary);
    padding: 0.4rem; cursor: pointer; display: none;
}

/* ── Print ── */
@media print {
    .sidebar, .content-header, .btn, .no-print, .app-footer { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: white; color: oklch(20% 0 0); font-size: 12pt; }
    .card { background: white; border: 1px solid oklch(80% 0 0); page-break-inside: avoid; }
    h1, h2, h3 { page-break-after: avoid; color: oklch(15% 0 0); }
    table { font-size: 10pt; }
    a { text-decoration: none; color: inherit; }
}
