/* =============================================================================
   UD Mobiles & Bijasan Electronics — Admin UI styles
   Palette derived from the printed invoice: navy + orange on white.
   ============================================================================= */

:root {
    --brand-primary:        #1a3a82;
    --brand-primary-dark:   #142d66;
    --brand-primary-light:  #2a4fa3;
    --brand-accent:         #f57c1c;
    --brand-accent-dark:    #d96911;

    --color-bg:             #f5f7fb;
    --color-surface:        #ffffff;
    --color-border:         #e3e7ef;
    --color-border-strong:  #c9d0dd;

    --color-text:           #1f2937;
    --color-text-muted:     #6b7280;
    --color-text-soft:      #9ca3af;

    --color-success:        #16a34a;
    --color-success-soft:   #dcfce7;
    --color-warning:        #d97706;
    --color-warning-soft:   #fef3c7;
    --color-danger:         #dc2626;
    --color-danger-soft:    #fee2e2;
    --color-info:           #2563eb;
    --color-info-soft:      #dbeafe;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);

    --sidebar-w:    248px;
    --topbar-h:     60px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-dark); }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--color-text); }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--brand-primary);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(15, 23, 42, 0.04);
    z-index: 20;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar__brand-logo {
    width: 40px;
    height: 40px;
    background: var(--color-surface);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--brand-primary);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
}
.sidebar__brand-text { line-height: 1.15; }
.sidebar__brand-name { font-weight: 700; font-size: 14px; letter-spacing: 0.2px; }
.sidebar__brand-sub  { font-size: 11px; opacity: 0.7; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar__section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.6; padding: 14px 12px 6px; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar__link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar__link.is-active {
    background: var(--brand-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(245, 124, 28, 0.35);
}
.sidebar__link svg { flex-shrink: 0; opacity: 0.9; }

.sidebar__user {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar__avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--brand-accent);
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px;
}
.sidebar__user-name { font-size: 13px; font-weight: 600; }
.sidebar__user-role { font-size: 11px; opacity: 0.7; }
.sidebar__user-logout {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.sidebar__user-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

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

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__title { font-size: 16px; font-weight: 600; }
.topbar__search {
    flex: 1;
    max-width: 380px;
    position: relative;
}
.topbar__search input {
    width: 100%;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 0 12px 0 38px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.topbar__search input:focus { border-color: var(--brand-primary); background: #fff; }
.topbar__search svg { position: absolute; left: 12px; top: 11px; color: var(--color-text-soft); }

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content {
    flex: 1;
    padding: 24px;
}

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header__sub { color: var(--color-text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card__header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card__title { font-size: 14px; font-weight: 600; }
.card__body { padding: 18px; }
.card__footer { padding: 14px 18px; border-top: 1px solid var(--color-border); background: #fafbfd; border-radius: 0 0 var(--radius-md) var(--radius-md); }

/* Stat card */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.stat-card__icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: var(--color-info-soft);
    color: var(--color-info);
    flex-shrink: 0;
}
.stat-card__icon--accent  { background: #fef0e1; color: var(--brand-accent); }
.stat-card__icon--success { background: var(--color-success-soft); color: var(--color-success); }
.stat-card__icon--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.stat-card__icon--danger  { background: var(--color-danger-soft);  color: var(--color-danger); }

.stat-card__label { color: var(--color-text-muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card__value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-card__meta  { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.stat-card__meta--up   { color: var(--color-success); }
.stat-card__meta--down { color: var(--color-danger); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
    white-space: nowrap;
}
.btn:hover { border-color: var(--color-border-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.btn--primary:hover { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); color: #fff; }

.btn--accent { background: var(--brand-accent); color: #fff; border-color: var(--brand-accent); }
.btn--accent:hover { background: var(--brand-accent-dark); border-color: var(--brand-accent-dark); color: #fff; }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--color-bg); }

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

.btn--sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn--lg { height: 44px; padding: 0 22px; font-size: 14px; }
.btn--icon { width: 38px; padding: 0; justify-content: center; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}
.label__req { color: var(--color-danger); }

.input, .select, .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    color: var(--color-text);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(26, 58, 130, 0.08);
}
.input--lg { height: 46px; font-size: 14px; }
.input:disabled, .select:disabled { background: var(--color-bg); color: var(--color-text-soft); cursor: not-allowed; }

.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; flex: 1; }
.input-group .input:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.input-group .input:last-child  { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.input-group__addon {
    display: grid; place-items: center;
    padding: 0 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-left: 0;
    color: var(--color-text-muted);
    font-size: 13px;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}
.input-group__addon--left {
    border-left: 1px solid var(--color-border);
    border-right: 0;
    border-radius: 8px 0 0 8px;
}

/* Radio / Checkbox cards */
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--color-border-strong); }
.choice input { accent-color: var(--brand-primary); }
.choice.is-active {
    border-color: var(--brand-primary);
    background: rgba(26, 58, 130, 0.05);
    color: var(--brand-primary);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafd;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfd; }
.table__num { text-align: right; font-variant-numeric: tabular-nums; }
.table__center { text-align: center; }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Editable table (used in billing-new) */
.editable-row td { padding: 8px; }
.editable-row .input, .editable-row .select { height: 36px; font-size: 13px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge--success { background: var(--color-success-soft); color: #166534; }
.badge--warning { background: var(--color-warning-soft); color: #92400e; }
.badge--danger  { background: var(--color-danger-soft);  color: #991b1b; }
.badge--info    { background: var(--color-info-soft);    color: #1e40af; }
.badge--accent  { background: #fef0e1; color: var(--brand-accent-dark); }
.badge--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-text-muted); }
.empty-state__icon { font-size: 36px; margin-bottom: 8px; opacity: 0.6; }
.empty-state__title { font-size: 15px; font-weight: 600; color: var(--color-text); margin-bottom: 4px; }
.empty-state__sub   { font-size: 13px; }

/* ---------- Login screen ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
}
.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.login-brand__logo {
    width: 64px; height: 64px;
    border-radius: 14px;
    background: var(--brand-primary);
    display: grid; place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 26px;
    letter-spacing: -1px;
}
.login-brand__name { font-size: 16px; font-weight: 700; color: var(--brand-primary); text-align: center; }
.login-brand__sub  { font-size: 12px; color: var(--brand-accent); text-align: center; }
.login-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--color-text-muted); text-align: center; margin-bottom: 24px; }

/* ---------- Utilities ---------- */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

.text-muted { color: var(--color-text-muted); }
.text-soft  { color: var(--color-text-soft); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-primary { color: var(--brand-primary); }
.text-accent  { color: var(--brand-accent); }
.text-bold    { font-weight: 700; }
.text-semibold { font-weight: 600; }

.text-mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.text-rupee::before { content: '₹ '; }

.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Two-column layout helper */
.layout-2col { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
@media (max-width: 1100px) { .layout-2col { grid-template-columns: 1fr; } }

/* ---------- Typeahead (AJAX product search) ---------- */
.typeahead { position: relative; }
.typeahead__dropdown {
    /* position: fixed so the dropdown escapes any .table-wrap / overflow:auto parent.
       Coordinates (top, left, width) are set by JS on open(). */
    position: fixed;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}
.typeahead__dropdown.is-open { display: block; }
.typeahead__option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
}
.typeahead__option:last-child { border-bottom: 0; }
.typeahead__option:hover,
.typeahead__option.is-active { background: rgba(26, 58, 130, 0.05); }
.typeahead__option-main { flex: 1; min-width: 0; }
.typeahead__option-name { font-weight: 600; color: var(--color-text); }
.typeahead__option-meta { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.typeahead__option-stock { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.typeahead__option-stock--ok  { background: var(--color-success-soft); color: #166534; }
.typeahead__option-stock--low { background: var(--color-warning-soft); color: #92400e; }
.typeahead__option-stock--out { background: var(--color-danger-soft);  color: #991b1b; }
.typeahead__empty { padding: 16px; text-align: center; color: var(--color-text-muted); font-size: 12px; }
.typeahead__chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: rgba(26, 58, 130, 0.08);
    border: 1px solid var(--brand-primary);
    border-radius: 8px;
    font-size: 13px;
}
.typeahead__chip-main { flex: 1; min-width: 0; }
.typeahead__chip-name { font-weight: 600; color: var(--brand-primary); }
.typeahead__chip-meta { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.typeahead__chip-clear {
    background: transparent; border: 0; cursor: pointer;
    color: var(--color-text-muted); font-size: 18px; line-height: 1; padding: 2px 6px;
}
.typeahead__chip-clear:hover { color: var(--color-danger); }
.hidden { display: none !important; }

/* ---------- Modal (simple, JS toggled by .is-open) ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal__title { font-size: 15px; font-weight: 600; }
.modal__close { background: none; border: 0; cursor: pointer; padding: 4px; color: var(--color-text-muted); }
.modal__body  { padding: 20px; }
.modal__footer{ padding: 14px 20px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfd; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 18px; }
.tab {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    background: transparent;
    border-top: 0;
    border-left: 0;
    border-right: 0;
}
.tab:hover { color: var(--color-text); }
.tab.is-active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.is-open { transform: translateX(0); }
    .main { margin-left: 0; }
}

/* ---------- Print: hide app shell on print pages ---------- */
@media print {
    .sidebar, .topbar { display: none; }
    .main { margin-left: 0; }
    .content { padding: 0; }
}
