/* ═══════════════════════════════════════════════════════════
   Fabric POS — Core Stylesheet
   Dark industrial aesthetic with fabric texture accents
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Playfair+Display:wght@700;900&family=Syne:wght@400;600;700&display=swap');
:root {
    /* ── Base ── */
    --bg: #ffffff;
    --surface: #f8fafc;
    --surface2: #f0f4f8;

    /* ── Borders ── */
    --border: #e2e8f0;
    --border2: #c5cfe0;

    /* ── Brand ── */
    --accent: #0a2463;       /* Navy primary — buttons, active nav, headings */
    --accent-d: #071a4a;     /* Navy dark — hover states */
    --accent2: #0d1f5c;      /* Navy deeper — secondary accent */

    /* ── Highlights ── */
    --blue: #1565c0;         /* Standard blue — links, info badges, highlights */
    --purple: #1565c0;       /* Unified with blue */
    --accent3: #1565c0;

    /* ── Text ── */
    --text: #0d1b2a;         /* Primary text — near-black on white */
    --text2: #4a6080;        /* Secondary text — labels, subtitles */
    --muted: #8a99a8;        /* Muted text — timestamps, metadata */

    /* ── Semantic ── */
    --danger: #c62828;       /* Red — errors, low stock, overdue */
    --success: #2e7d32;      /* Green — paid, in stock, confirmed */
    --warning: #e65100;      /* Amber-orange — caution notes */

    /* ── Shadows ── */
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 2px 12px rgba(10, 36, 99, 0.08);
    --shadow-lg: 0 8px 32px rgba(10, 36, 99, 0.12);

    --sidebar-w: 240px;
    --topbar-h: 60px;
}
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Syne', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Grain texture overlay ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.6;
}

/* ────────────────────────────────────────────────────────────
   LAYOUT
──────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .logo-icon {
    font-size: 22px;
    width: 38px;
    height: 38px;
    background: #0a1a12;
    border: 1px solid var(--accent-d);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo .logo-text {
    font-family: 'Playfair Display', serif;
    font-size: 15px;
    color: var(--accent);
    line-height: 1.2;
}

.sidebar-logo .logo-sub {
    font-size: 9px;
    color: var(--muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-family: 'DM Mono', monospace;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 20px 6px;
    font-family: 'DM Mono', monospace;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    border-left: 2px solid transparent;
    position: relative;
}

.nav-item:hover {
    color: var(--text);
    background: var(--surface2);
}

.nav-item.active {
    color: var(--accent);
    background: rgba(93, 255, 176, 0.05);
    border-left-color: var(--accent);
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.nav-badge {
    margin-left: auto;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 20px;
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent3);
    font-family: 'DM Mono', monospace;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--surface2);
    border: 1px solid var(--border);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-d), #05296c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #0a1a12;
    flex-shrink: 0;
}

.user-info .user-name {
    font-size: 12px;
    font-weight: 600;
}

.user-info .user-role {
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'DM Mono', monospace;
}

/* ── Main content ── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 15px;
    font-weight: 700;
    flex: 1;
}

.topbar-subtitle {
    font-size: 11px;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
}

.page-content {
    padding: 28px;
    flex: 1;
}

/* ────────────────────────────────────────────────────────────
   COMPONENTS
──────────────────────────────────────────────────────────── */

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.card-subtitle {
    font-size: 10px;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    margin-top: 2px;
}

/* ── Stat Cards ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.stat-card.green::before {
    background: var(--accent);
}

.stat-card.yellow::before {
    background: var(--accent2);
}

.stat-card.blue::before {
    background: var(--blue);
}

.stat-card.red::before {
    background: var(--accent3);
}

.stat-card:hover {
    border-color: var(--border2);
}

.stat-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-family: 'DM Mono', monospace;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'DM Mono', monospace;
    line-height: 1;
}

.stat-card.green .stat-value {
    color: #0a396b;
}

.stat-card.yellow .stat-value {
    color: var(--accent2);
}

.stat-card.blue .stat-value {
    color: var(--blue);
}

.stat-card.red .stat-value {
    color: var(--accent3);
}

.stat-change {
    font-size: 10px;
    color: var(--muted);
    margin-top: 6px;
    font-family: 'DM Mono', monospace;
}

.stat-icon {
    position: absolute;
    right: 18px;
    top: 18px;
    font-size: 22px;
    opacity: 0.2;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 700;
    font-family: 'Syne', sans-serif;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.15s;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-d);
    border-color: var(--accent-d);
}

.btn-secondary {
    background:#1565c0;
    color:#ffffff;
    border-color: var(--border2);
}

.btn-secondary:hover {
    border-color: var(--accent-d);
    color: var(--accent);
}

.btn-danger {
    background: rgba(255, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(255, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(255, 68, 68, 0.2);
}

.btn-ghost {
    background: #2e7d32;
    color: #ffffff;
    border-color: var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 14px;
}

.btn-icon {
    padding: 8px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: 'DM Mono', monospace;
}

.form-control {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 13px;
    font-family: 'Syne', sans-serif;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-d);
    box-shadow: 0 0 0 3px rgba(93, 255, 176, 0.08);
}

.form-control::placeholder {
    color: var(--muted);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ── Badges / Pills ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    font-family: 'DM Mono', monospace;
}

.badge-green {
    background: rgba(17, 101, 165, 0.1);
    color: var(--accent);
    border: 1px solid rgba(78, 48, 227, 0.404);
}

.badge-yellow {
    background: rgba(255, 206, 93, 0.1);
    color: var(--accent2);
    border: 1px solid rgba(255, 206, 93, 0.2);
}

.badge-red {
    background: rgba(255, 107, 107, 0.1);
    color: var(--accent3);
    border: 1px solid rgba(255, 107, 107, 0.2);
}

.badge-blue {
    background: rgba(126, 184, 255, 0.1);
    color: var(--blue);
    border: 1px solid rgba(126, 184, 255, 0.2);
}

.badge-muted {
    background: rgba(74, 94, 82, 0.2);
    color: var(--muted);
    border: 1px solid var(--border);
}

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 16px;
    border-left: 3px solid;
}

.alert-success {
    background: rgba(93, 255, 176, 0.07);
    border-color: var(--accent);
    color: var(--accent);
}

.alert-danger {
    background: rgba(255, 68, 68, 0.07);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(255, 206, 93, 0.07);
    border-color: var(--accent2);
    color: var(--accent2);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 15px;
    font-weight: 700;
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
}

/* ── Search box ── */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 36px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
}

/* ── Misc ── */
.text-accent {
    color: var(--accent);
}

.text-muted {
    color: var(--muted);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-mono {
    font-family: 'DM Mono', monospace;
}

.text-sm {
    font-size: 11px;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.flex {
    display: flex;
}

.flex-center {
    display: block;
    align-items: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

.gap-16 {
    gap: 16px;
}

.mt-8 {
    margin-top: 8px;
}

.mt-16 {
    margin-top: 16px;
}

.mt-24 {
    margin-top: 24px;
}

.mb-16 {
    margin-bottom: 16px;
}

.mb-24 {
    margin-bottom: 24px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── Low stock indicator ── */
.stock-low {
    color: var(--accent3);
}

.stock-ok {
    color: var(--accent);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* ── Toast notifications ── */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid;
    animation: slideIn 0.2s ease;
    max-width: 300px;
}

.toast-success {
    background: #0a1f14;
    color: var(--accent);
    border-color: rgba(93, 255, 176, 0.3);
}

.toast-error {
    background: #1f0a0a;
    color: var(--danger);
    border-color: rgba(255, 68, 68, 0.3);
}

.toast-warning {
    background: #1f160a;
    color: var(--accent2);
    border-color: rgba(255, 206, 93, 0.3);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── Print styles ── */
@media print {

    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .main {
        margin-left: 0;
    }

    body {
        background: white;
        color: black;
    }
}