@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #1e3a5f;
    --primary-light: #2a4f80;
    --accent:     #f97316;
    --accent-hover: #ea6c00;
    --bg:         #f0f4f8;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #1e293b;
    --muted:      #64748b;
    --success:    #16a34a;
    --danger:     #dc2626;
    --radius:     8px;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,.1);
}

body {
    font-family: 'Fira Sans', system-ui, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ─── NAV ─────────────────────────────────────────────── */
nav {
    background: var(--primary);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 52px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    margin-right: auto;
    letter-spacing: -.2px;
}
.nav-brand svg { opacity: .9; }
nav a {
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
nav a.active { color: #fff; background: rgba(255,255,255,.15); }

/* ─── LAYOUT ──────────────────────────────────────────── */
.container { max-width: 1440px; margin: 0 auto; padding: 24px 24px 80px; }

.page-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}
.page-header .subtitle {
    font-size: 13px;
    color: var(--muted);
}

/* ─── CARDS ───────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* ─── PRODUCT HERO ────────────────────────────────────── */
#product-image {
    display: none;
    align-items: center;
    gap: 20px;
    background: var(--primary);
    padding: 20px 24px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
}
#product-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,.25);
    flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-meta {
    font-size: 12px;
    color: rgba(255,255,255,.6);
    margin-top: 4px;
    display: flex;
    gap: 16px;
}
.product-meta strong { color: rgba(255,255,255,.9); }

/* ─── TOOLBAR SECTION ─────────────────────────────────── */
.toolbar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.toolbar-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.toolbar-row + .toolbar-row { margin-top: 10px; }

.toolbar-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

/* ─── FORMS ───────────────────────────────────────────── */
select, input[type="text"], input[type="password"], input[type="number"] {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    cursor: pointer;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,.1);
    cursor: text;
}
label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
label input, label select {
    display: block;
    width: 100%;
    max-width: 380px;
    margin-top: 4px;
}
.settings-section { padding: 24px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; }
.settings-section h2 { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 16px; }

/* ─── BUTTONS ─────────────────────────────────────────── */
button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: background .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}
button:hover { background: var(--primary-light); box-shadow: var(--shadow-sm); }
button:active { transform: scale(.98); }
button svg { flex-shrink: 0; }

button.accent { background: var(--accent); }
button.accent:hover { background: var(--accent-hover); }
button.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #f8fafc; }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
button.ghost { background: transparent; color: var(--muted); border: none; padding: 5px 8px; }
button.ghost:hover { background: #f1f5f9; color: var(--text); box-shadow: none; }
button.sm { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ─── ACTION BAR ──────────────────────────────────────── */
#action-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    flex-wrap: wrap;
}
#action-bar.visible { display: flex; }
#action-bar input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    border: 2px solid var(--primary);
    flex-shrink: 0;
}
.selection-info {
    font-size: 13px;
    font-weight: 600;
    color: #1d4ed8;
    margin-right: 4px;
}

/* ─── TABLE ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead { position: static; }
th {
    background: #f8fafc;
    padding: 9px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
th.num { width: 40px; text-align: center; }
th.cb  { width: 36px; vertical-align: middle; overflow: visible; padding-top: 12px; }
th.cb input[type="checkbox"],
td input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--primary);
    display: block;
}
td {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
tbody tr.selected td { background: #eff6ff; }

td.num {
    text-align: center;
    color: #cbd5e1;
    font-size: 11px;
    font-family: 'Fira Code', monospace;
}
td.sku {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
}
td.price {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 500;
}
td.price-empty { color: #cbd5e1; font-family: 'Fira Code', monospace; font-size: 13px; }

.badge-active   { display:inline-flex; align-items:center; gap:4px; padding:3px 8px; border-radius:20px; font-size:11px; font-weight:600; background:#dcfce7; color:#15803d; }
.badge-inactive { display:inline-flex; align-items:center; gap:4px; padding:3px 8px; border-radius:20px; font-size:11px; font-weight:600; background:#fee2e2; color:#b91c1c; }
.badge-active::before   { content:''; width:6px; height:6px; border-radius:50%; background:#16a34a; }
.badge-inactive::before { content:''; width:6px; height:6px; border-radius:50%; background:#dc2626; }

.inline-edit { cursor: text; }
.inline-edit:hover { background: #fefce8 !important; }
.inline-input {
    width: 80px;
    padding: 3px 6px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Fira Code', monospace;
}

/* ─── BULK MODAL ──────────────────────────────────────── */
#bulk-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(2px);
    z-index: 40;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
#bulk-overlay.visible { display: flex; }

#bulk-panel {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 780px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    animation: modalIn .2s ease;
    overflow: hidden;
}
@keyframes modalIn {
    from { transform: translateY(16px) scale(.98); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.bulk-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--primary);
}
.bulk-panel-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.bulk-panel-header h2 svg { opacity: .85; }
.bulk-count-badge {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    letter-spacing: .2px;
}
.bulk-panel-header button.ghost {
    color: rgba(255,255,255,.7);
    padding: 4px;
    border-radius: 4px;
}
.bulk-panel-header button.ghost:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.bulk-body { padding: 20px 24px; }

.bulk-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (max-width: 600px) { .bulk-grid { grid-template-columns: 1fr 1fr; } }

.bulk-section {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    transition: border-color .15s;
}
.bulk-section:has(input[type="radio"]:not([value="none"]):checked) {
    border-color: var(--primary);
    background: #f0f5ff;
}
.bulk-section h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.bulk-section label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    font-weight: 400;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background .1s;
}
.bulk-section label:hover { background: rgba(30,58,95,.05); }
.bulk-section input[type="radio"] { accent-color: var(--primary); cursor: pointer; }
.bulk-section input[type="number"] {
    width: 100%;
    margin-top: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    padding: 6px 10px;
    max-width: none;
}

.bulk-footer {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

/* ─── LOADING SKELETON ────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: 4px;
    height: 14px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── TOAST ───────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: slideIn .2s ease;
    min-width: 240px;
    max-width: 360px;
}
.toast.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.toast.error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.toast.info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }

/* ─── SPINNER ─────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 15px; height: 15px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
}
.spinner.dark { border-color: #e2e8f0; border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── MISC ────────────────────────────────────────────── */
.success-msg { color: var(--success); font-size: 13px; }
.error-msg   { color: var(--danger);  font-size: 13px; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--primary); }
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 340px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo svg { color: var(--primary); }
.login-box h1 { font-size: 20px; font-weight: 700; margin-bottom: 6px; text-align: center; color: var(--primary); }
.login-subtitle { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-box label { font-weight: 600; font-size: 13px; }
.login-box input { max-width: 100%; margin-top: 4px; margin-bottom: 16px; }
.login-box button { width: 100%; padding: 10px; font-size: 14px; justify-content: center; }

/* Settings page */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 640px; }
@media (max-width: 600px) { .settings-grid { grid-template-columns: 1fr; } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── COUPON GENERATOR ─────────────────────────────────── */
.coupon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.field-group input,
.field-group select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s;
}

.field-group input:focus,
.field-group select:focus {
    outline: none;
    border-color: var(--primary-light);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table code {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: .05em;
}

.coupon-section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.coupon-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
}
