/* ═══════════════════════════════════════════
   QuickPOS — Main Stylesheet
   Clean, professional, touch-friendly.
   ═══════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --success: #0f9d58;
    --success-light: #e6f4ea;
    --danger: #d93025;
    --danger-light: #fce8e6;
    --warning: #f9ab00;
    --warning-light: #fef7e0;
    --text: #202124;
    --text-secondary: #5f6368;
    --border: #dadce0;
    --bg: #f8f9fa;
    --white: #ffffff;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.15);
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    min-height: 100vh;
}

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

img { max-width: 100%; height: auto; }

/* ── Sidebar ──────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 1000;
    transition: transform .25s ease;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .9rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.user-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .75rem; color: var(--text-secondary); }

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text);
    font-size: .9rem;
    transition: background .15s;
    min-height: 44px;
}
.sidebar-nav li a:hover { background: var(--bg); text-decoration: none; }
.sidebar-nav li a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-nav li a.nav-logout { color: var(--danger); }
.sidebar-nav li a.nav-logout:hover { background: var(--danger-light); }

.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 20px; }

/* ── Main Content ─────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.business-name { font-size: .85rem; color: var(--text-secondary); }

.content-area {
    padding: 24px;
    max-width: 1200px;
}

/* ── Cards ────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }

/* ── Stat Cards (Dashboard) ───────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.stat-card .stat-label {
    font-size: .8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-danger .stat-value { color: var(--danger); }
.stat-card.stat-primary .stat-value { color: var(--primary); }
.stat-card.stat-warning .stat-value { color: var(--warning); }

/* ── Tables ───────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
thead th {
    text-align: left;
    padding: 12px;
    background: var(--bg);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:hover { background: #f1f3f4; }

/* ── Forms ────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .95rem;
    font-family: inherit;
    background: var(--white);
    transition: border-color .15s;
    min-height: 44px;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

select.form-control {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%235f6368' d='M1.4 0L6 4.6 10.6 0 12 1.4l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* ── Buttons ──────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    transition: background .15s, transform .1s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0b8043; }

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

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

.btn-sm { padding: 6px 12px; font-size: .8rem; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Alerts ───────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: .9rem;
}
.alert-success { background: var(--success-light); color: #137333; border: 1px solid #ceead6; }
.alert-error   { background: var(--danger-light);  color: #c5221f; border: 1px solid #fad2cf; }
.alert-warning { background: var(--warning-light); color: #e37400; border: 1px solid #fde293; }
.alert-info    { background: var(--primary-light); color: #1967d2; border: 1px solid #aecbfa; }

/* ── Badges ───────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.3;
}
.badge-success { background: var(--success-light); color: #137333; }
.badge-danger  { background: var(--danger-light);  color: #c5221f; }
.badge-warning { background: var(--warning-light); color: #e37400; }
.badge-primary { background: var(--primary-light); color: #1967d2; }

/* ── Empty State ──────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* ── Pagination ───────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .85rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Low Stock Widget ─────────────────────── */
.low-stock-list { list-style: none; }
.low-stock-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
.low-stock-list li:last-child { border-bottom: none; }
.stock-count { font-weight: 700; }
.stock-critical { color: var(--danger); }
.stock-low { color: var(--warning); }

/* ── Search Bar ───────────────────────────── */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}
.search-bar input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .95rem;
    min-height: 44px;
}
.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}
.search-bar::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .9rem;
}

/* ── Filter Bar ───────────────────────────── */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filter-bar .form-group { margin-bottom: 0; }

/* ── Quick Actions Grid ───────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    color: var(--text);
    transition: box-shadow .15s, transform .1s;
    min-height: 44px;
}
.quick-action:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.quick-action .qa-icon { font-size: 1.8rem; }
.quick-action .qa-label { font-size: .85rem; font-weight: 600; }

/* ── Login Page ───────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
}
.login-box .logo { text-align: center; margin-bottom: 32px; }
.login-box .logo h1 { font-size: 1.5rem; color: var(--primary); }
.login-box .logo p { font-size: .85rem; color: var(--text-secondary); margin-top: 4px; }

/* ── Dashboard Grid ───────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-close { display: block; }
    .hamburger { display: flex; }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .top-bar { padding: 0 12px; }
    .page-title { font-size: 1rem; }
    .business-name { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .btn-group { flex-direction: column; }
}

/* ── Overlay for mobile sidebar ───────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ── Utility ──────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
