/* ============================================================
   Grocery Store POS — Application stylesheet
   Bootstrap 5.3 overrides + custom dashboard components
   ============================================================ */

:root {
    --brand: #16a34a;
    --brand-dark: #15803d;
    --brand-darker: #14532d;
    --brand-soft: #dcfce7;
    --sidebar-bg: #0d2f22;
    --sidebar-bg-hover: #123b2c;
    --sidebar-text: #c9e6d8;
    --sidebar-muted: #7fb096;
    --bg: #f4f6f9;
    --card-border: #e7eaee;
    --text: #1f2937;
    --muted: #6b7280;
    --radius: 0.75rem;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 0.925rem;
    line-height: 1.5;
}

/* ------------------------------------------------------------
   App shell
   ------------------------------------------------------------ */
.app-shell { min-height: 100vh; display: flex; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0a241a 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand-icon {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand); color: #fff;
    border-radius: 10px; font-size: 1.1rem;
}
.brand-text { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.page-logo { height: 46px; width: auto; max-width: 150px; object-fit: contain; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0.75rem 1rem; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-group { margin-top: 1rem; }
.nav-group-title {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
    color: var(--sidebar-muted); padding: 0.25rem 0.65rem; margin-bottom: 0.25rem;
    font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.52rem 0.7rem; margin-bottom: 2px;
    color: var(--sidebar-text); text-decoration: none;
    border-radius: 8px; font-size: 0.875rem; font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item i { font-size: 1rem; width: 20px; text-align: center; }
.nav-item:hover { background: var(--sidebar-bg-hover); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item.nav-disabled { opacity: 0.55; }
.nav-item.nav-disabled:hover { background: transparent; color: var(--sidebar-text); cursor: default; }

.soon-badge { font-size: 0.58rem; font-weight: 600; background: rgba(255,255,255,0.12); color: var(--sidebar-text); margin-left: auto; }

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.82rem;
}
.sidebar-avatar { width: 34px; height: 34px; object-fit: cover; }
.avatar-fallback {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand-dark);
    font-weight: 700; font-size: 0.85rem;
}
.sidebar-user-name { color: #fff; font-weight: 600; }
.sidebar-user-role { color: var(--sidebar-muted); text-transform: capitalize; }

.sidebar-backdrop { display: none; }

/* ------------------------------------------------------------
   Topbar
   ------------------------------------------------------------ */
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 1.5rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--card-border);
}
.topbar-title { font-weight: 600; }
.btn-icon {
    border: 1px solid var(--card-border); background: #fff; color: var(--text);
    border-radius: 8px; width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative;
}
.btn-icon:hover { background: #f8fafc; }
.btn-icon-xs { width: 26px; height: 26px; font-size: 0.7rem; border-radius: 6px; }
.notify-badge {
    position: absolute; top: -5px; right: -5px;
    background: #ef4444; font-size: 0.6rem; padding: 0.15rem 0.35rem;
}
.topbar-search {
    position: relative; width: 260px;
}
.topbar-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; }
.topbar-search .form-control { padding-left: 32px; background: var(--bg); border-color: transparent; }
.topbar-avatar { width: 34px; height: 34px; object-fit: cover; }

.notify-dropdown { width: 340px; padding: 0; max-height: 480px; display: flex; flex-direction: column; }
.dropdown-menu.notify-dropdown.show { display: flex; }
.notify-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--card-border); }
.notify-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.notify-item {
    position: relative; display: flex; align-items: stretch;
    border-bottom: 1px solid #f3f4f6;
}
.notify-item:hover { background: #f9fafb; }
.notify-item.notify-unread { background: #f0fdf4; }
.notify-link { display: flex; gap: 0.7rem; padding: 0.65rem 2.1rem 0.65rem 1rem; flex-grow: 1; min-width: 0; text-decoration: none; color: var(--text); }
.notify-link:hover { color: var(--text); }
.notify-remove {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%; background: transparent; color: var(--muted);
    font-size: 0.8rem; padding: 0;
}
.notify-remove:hover { background: #fee2e2; color: #dc2626; }
.notify-title { font-weight: 600; font-size: 0.85rem; }
.notify-msg { font-size: 0.78rem; color: var(--muted); }
.notify-time { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.notify-footer { display: block; text-align: center; padding: 0.6rem; font-size: 0.82rem; color: var(--brand-dark); text-decoration: none; border-top: 1px solid var(--card-border); }

/* ------------------------------------------------------------
   Content
   ------------------------------------------------------------ */
.app-content { flex: 1; padding: 1.4rem 1.5rem 2rem; max-width: 1600px; width: 100%; margin: 0 auto; }

.page-heading {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-heading h4 { font-weight: 700; }
.page-actions { display: flex; gap: 0.5rem; }

.app-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.9rem 1.5rem; border-top: 1px solid var(--card-border);
    background: #fff;
}

/* ------------------------------------------------------------
   Cards & stats
   ------------------------------------------------------------ */
.card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header { border-bottom: 1px solid var(--card-border); font-size: 0.9rem; }

.stat-card {
    display: flex; align-items: center; gap: 0.9rem;
    padding: 1.1rem 1.2rem;
}
.stat-icon {
    width: 52px; height: 52px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; font-size: 1.4rem;
}
.stat-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 500; }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 22, 163, 74;
    border-radius: 8px;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-dark);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    border-radius: 8px;
}
.btn { border-radius: 8px; }

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
.table thead th {
    background: #f8fafc;
    font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--muted); font-weight: 600;
    border-bottom: 1px solid var(--card-border); white-space: nowrap;
}
.table td { vertical-align: middle; font-size: 0.87rem; }
.table-hover tbody tr:hover { background: #f9fafb; }

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.form-control, .form-select, .input-group-text {
    border-radius: 8px; font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(22, 163, 74, 0.12);
}
.input-group-text { background: #f8fafc; }

/* ------------------------------------------------------------
   Auth pages
   ------------------------------------------------------------ */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f3b2c 0%, #14532d 45%, #16a34a 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.auth-wrap { width: 100%; max-width: 440px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; color: #fff; }
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 0.75rem;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
    border-radius: 18px; display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #fff;
}
.auth-brand h1 { font-size: 1.5rem; font-weight: 800; }
.auth-brand p { opacity: 0.85; font-size: 0.85rem; margin: 0; }
.auth-card { border-radius: 16px; border: none; }
.auth-title { font-weight: 700; }
.auth-link { color: var(--brand-dark); text-decoration: none; font-size: 0.85rem; }
.auth-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------
   Lists / empty states / misc
   ------------------------------------------------------------ */
.rank-badge {
    width: 26px; height: 26px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand-dark);
    border-radius: 8px; font-size: 0.75rem; font-weight: 700;
}
.empty-state-icon { font-size: 2rem; color: #cbd5e1; }
.empty-state h6 { font-weight: 600; }
.empty-state p { max-width: 260px; margin-left: auto; margin-right: auto; }

.profile-avatar { width: 96px; height: 96px; object-fit: cover; font-size: 2rem; }

.error-page {
    max-width: 480px; margin: 8vh auto; text-align: center; padding: 2rem;
}
.error-code {
    font-size: 5rem; font-weight: 800; line-height: 1;
    background: linear-gradient(135deg, var(--brand), #0ea5e9);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

.app-alert { border-radius: 10px; }

.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); }

/* ------------------------------------------------------------
   Dashboard
   ------------------------------------------------------------ */
.chart-wrap { position: relative; height: 270px; }
.chart-wrap-sm { position: relative; height: 210px; }

.demo-banner {
    border: 1px dashed var(--brand);
    background: linear-gradient(135deg, rgba(22,163,74,0.06), rgba(14,165,233,0.05));
    border-radius: var(--radius);
}

.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.qa-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.45rem; padding: 0.85rem 0.4rem; border-radius: 10px;
    border: 1px solid var(--card-border); background: #fff;
    color: var(--text); font-size: 0.78rem; font-weight: 600;
    text-decoration: none; transition: border-color 0.15s ease, transform 0.15s ease;
}
.qa-tile:hover:not(.qa-disabled) { border-color: var(--brand); color: var(--brand-dark); transform: translateY(-2px); }
.qa-tile i { font-size: 1.25rem; }
.qa-tile.qa-disabled {
    opacity: 0.55; cursor: not-allowed; color: var(--muted);
}
.qa-tile.qa-disabled i { color: #94a3b8; }

.list-thumb {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.95rem; font-weight: 700;
}

.list-thumb-empty {
    background: #f1f5f9; color: #94a3b8; border: 1px dashed #cbd5e1;
}

.product-preview {
    max-height: 180px; object-fit: cover;
    border: 1px solid var(--card-border); border-radius: 10px;
}

.panel-list { max-height: 340px; overflow: hidden; }

.mini-spark { font-size: 0.72rem; color: var(--muted); }


/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 0 0 40px rgba(0,0,0,0.25);
    }
    .app-sidebar.sidebar-open { transform: translateX(0); }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(15, 23, 42, 0.5); z-index: 1039;
        opacity: 0; visibility: hidden; transition: opacity 0.2s ease;
    }
    .sidebar-backdrop.show { opacity: 1; visibility: visible; }
    .app-content { padding: 1rem; }
}
