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

:root {
    /* Color Palette */
    --primary-maroon: #800000;
    --primary-maroon-light: #a52a2a;
    --primary-maroon-dark: #4d0000;
    --milk-white: #fffdf0;
    --milk-white-dim: #f5f0e0;

    /* Theme: Milk White Background, Maroon Text */
    --bg-color: var(--milk-white);
    --text-main: var(--primary-maroon-dark);
    --text-muted: rgba(77, 0, 0, 0.6);

    /* Glassmorphism for Light Background */
    --glass-bg: rgba(255, 253, 240, 0.7);
    --glass-bg-solid: rgba(255, 253, 240, 0.95);
    --glass-bg-hover: rgba(128, 0, 0, 0.08);
    --glass-border: rgba(128, 0, 0, 0.15);
    --glass-shadow: 0 8px 32px rgba(77, 0, 0, 0.1);

    /* Accent */
    --danger: #c0392b;
    --success: #27ae60;
    --warning: #e67e22;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --transition-speed: 0.25s;
}

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

html, body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== GLASSMORPHISM ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
}

.glass-solid {
    background: var(--glass-bg-solid);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
}

.glass-hover {
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}
.glass-hover:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(77, 0, 0, 0.15);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.animate-fade-in { animation: fadeIn 0.5s ease forwards; }
.animate-slide-in { animation: slideIn 0.3s ease forwards; }

/* ===== APP LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    z-index: 200;
    background: var(--glass-bg-solid);
    border-right: 1px solid var(--glass-border);
    box-shadow: 4px 0 24px rgba(77, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    padding: 32px 20px;
}

.sidebar-logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-maroon);
    letter-spacing: -1px;
    margin-bottom: 8px;
    padding-left: 12px;
}

.sidebar-tagline {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding-left: 12px;
    margin-bottom: 40px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: all var(--transition-speed) ease;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-item:hover {
    background: var(--glass-bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-maroon);
    color: var(--milk-white);
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(128, 0, 0, 0.3);
}

.sidebar-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 20px 0;
}

.sidebar-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 28px;
    min-height: 100vh;
}

/* ===== TOP HEADER ===== */
.top-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    margin-bottom: 28px;
}

.top-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 30px;
    background: var(--glass-bg-hover);
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: color var(--transition-speed);
    padding: 4px;
}
.btn-logout:hover { color: var(--danger); }

/* ===== CARDS ===== */
.card {
    padding: 24px;
    margin-bottom: 24px;
}

.card-label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.card-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 8px;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i { color: var(--primary-maroon); }

/* ===== STAT GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(128, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary-maroon);
    margin-bottom: 16px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-maroon);
    color: var(--milk-white);
}
.btn-primary:hover {
    background: var(--primary-maroon-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(128, 0, 0, 0.35);
}

.btn-ghost {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}
.btn-ghost:hover {
    background: var(--glass-bg-hover);
}

.btn-danger {
    background: rgba(192, 57, 43, 0.1);
    color: var(--danger);
    border: 1px solid rgba(192, 57, 43, 0.2);
}
.btn-danger:hover {
    background: rgba(192, 57, 43, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ===== INPUTS ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.92rem;
    transition: all var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-maroon);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.08);
}

select.form-control {
    cursor: pointer;
}

/* ===== TABLES ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--glass-border);
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-speed);
    cursor: pointer;
}

tbody tr:hover {
    background: var(--glass-bg-hover);
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-danger {
    background: rgba(192, 57, 43, 0.12);
    color: var(--danger);
    border: 1px solid rgba(192, 57, 43, 0.2);
}

.badge-success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.badge-warning {
    background: rgba(230, 126, 34, 0.1);
    color: var(--warning);
    border: 1px solid rgba(230, 126, 34, 0.2);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(77, 0, 0, 0.25);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--glass-bg-solid);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(77, 0, 0, 0.2);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    animation: slideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-speed);
}
.modal-close:hover { color: var(--danger); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-footer .btn { flex: 1; justify-content: center; }

/* ===== LOW STOCK LIST ===== */
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--glass-border);
}
.alert-item:last-child { border-bottom: none; }
.alert-item-name { font-weight: 600; font-size: 0.9rem; }
.alert-item-sku { font-size: 0.8rem; color: var(--text-muted); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }

/* ===== SEARCH BAR ===== */
.search-wrap {
    position: relative;
}
.search-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}
.search-wrap .form-control {
    padding-left: 38px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,0,0,0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
}

/* ===== LOGIN PAGE ===== */
body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--milk-white) 0%, var(--milk-white-dim) 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 44px 40px;
    text-align: center;
    margin: 20px;
}

.auth-logo {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--primary-maroon);
    letter-spacing: -1.5px;
    margin-bottom: 4px;
}

.auth-tagline {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

.toggle-link {
    margin-top: 20px;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.toggle-link a {
    color: var(--primary-maroon);
    font-weight: 700;
    text-decoration: none;
}
.toggle-link a:hover { text-decoration: underline; }

.error-box {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid rgba(192, 57, 43, 0.25);
    color: var(--danger);
    font-size: 0.85rem;
    display: none;
    text-align: left;
}

.success-box {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    background: rgba(39, 174, 96, 0.1);
    border: 1px solid rgba(39, 174, 96, 0.25);
    color: var(--success);
    font-size: 0.85rem;
    display: none;
    text-align: left;
}

/* ===== ADVANCED FIELDS ===== */
.advanced-panel {
    display: none;
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
    margin-top: 4px;
}
.advanced-panel.open { display: block; }

/* ===== LANDING PAGE ===== */
body.landing-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--milk-white) 0%, var(--milk-white-dim) 100%);
    min-height: 100vh;
}

/* ===== DETAIL MODAL (Sales History Click) ===== */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-muted); }
.detail-row span:last-child { font-weight: 600; }

.img-preview-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.img-preview-row a {
    font-size: 0.8rem;
    color: var(--primary-maroon);
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
}
.img-preview-row a:hover { background: var(--glass-bg-hover); }
