/* =====================================================
   BarMS — Bar Management System CSS
   Theme: Industrial/Utilitarian with amber accents
   ===================================================== */

:root {
    --bg:         #0f0f0f;
    --bg-surface: #1a1a1a;
    --bg-card:    #222222;
    --bg-hover:   #2a2a2a;
    --border:     #333333;
    --border-light: #3d3d3d;

    --text:       #f0ede8;
    --text-muted: #888888;
    --text-dim:   #555555;

    --amber:      #f59e0b;
    --amber-dark: #d97706;
    --amber-glow: rgba(245,158,11,0.15);

    --green:      #22c55e;
    --red:        #ef4444;
    --yellow:     #eab308;
    --blue:       #3b82f6;

    --font-mono: 'Space Mono', monospace;
    --font-body: 'Inter', sans-serif;

    --radius: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.5);
    --transition: 0.18s ease;

    --sidebar-w: 220px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ─── Layout ─────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: 1px;
}

.brand-icon { font-size: 22px; }

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-left-color: var(--border-light);
}

.nav-item.active {
    background: var(--amber-glow);
    color: var(--amber);
    border-left-color: var(--amber);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-user {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.btn-logout {
    display: block;
    text-align: center;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 12px;
    transition: var(--transition);
}
.btn-logout:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.05); }

/* ─── Main Content ─────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 28px;
    max-width: 1200px;
    width: 100%;
}

/* ─── Page Header ─────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

.page-date {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ─── Flash messages ──────────────────────────────────── */
.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13px;
    border: 1px solid;
}
.flash-success { background: rgba(34,197,94,0.1); border-color: var(--green); color: var(--green); }
.flash-error   { background: rgba(239,68,68,0.1); border-color: var(--red);   color: var(--red); }

/* ─── Stats Grid ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }

.stat-primary { border-top: 3px solid var(--amber); }
.stat-secondary { border-top: 3px solid var(--blue); }
.stat-accent { border-top: 3px solid var(--green); }
.stat-warn { border-top: 3px solid var(--yellow); }

.stat-icon { font-size: 28px; }

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: var(--font-mono);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

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

/* ─── Cards ───────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text);
}

.link-small { font-size: 12px; color: var(--amber); }

/* ─── Table ───────────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: var(--bg-surface);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    border-bottom: 1px solid var(--border);
}

.table tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }

.table tfoot td {
    padding: 10px 16px;
    border-top: 2px solid var(--border);
    background: var(--bg-surface);
}

.text-bold { font-weight: 600; font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ─── Badges ──────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.5px;
}
.badge-ok     { background: rgba(34,197,94,0.15);  color: var(--green); }
.badge-warn   { background: rgba(234,179,8,0.15);  color: var(--yellow); }
.badge-danger { background: rgba(239,68,68,0.15);  color: var(--red); }

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    white-space: nowrap;
}

.btn-primary {
    background: var(--amber);
    color: #0f0f0f;
    border-color: var(--amber);
    font-weight: 600;
}
.btn-primary:hover { background: var(--amber-dark); border-color: var(--amber-dark); color: #0f0f0f; }

.btn-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border-light);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-dim); }

.btn-danger {
    background: transparent;
    color: var(--red);
    border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--red); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; font-weight: 600; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Quick Actions ───────────────────────────────────── */
.quick-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

/* ─── Forms ───────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-family: var(--font-mono);
}

.form-group input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-glow);
}

.form-group input::placeholder { color: var(--text-dim); }

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

/* ─── Modal ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    animation: modal-in 0.18s ease;
}

@keyframes modal-in {
    from { opacity:0; transform: scale(0.95) translateY(8px); }
    to   { opacity:1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
    font-family: var(--font-mono);
    font-size: 15px;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

/* ─── Actions Cell ────────────────────────────────────── */
.actions-cell { display: flex; gap: 6px; align-items: center; }

/* ─── POS Layout ──────────────────────────────────────── */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    height: calc(100vh - 120px);
    min-height: 500px;
}

.pos-products {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

.pos-search-bar input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    font-family: var(--font-body);
}
.pos-search-bar input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-glow); }
.pos-search-bar input::placeholder { color: var(--text-dim); }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding-right: 4px;
    flex: 1;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    user-select: none;
}

.product-card:hover:not(.out-of-stock) {
    border-color: var(--amber);
    background: var(--amber-glow);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(245,158,11,0.2);
}

.product-card.out-of-stock {
    opacity: 0.35;
    cursor: not-allowed;
}

.product-card-icon { font-size: 26px; }
.product-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.product-card-price {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--amber);
    font-weight: 700;
}
.product-card-stock {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ─── Cart ────────────────────────────────────────────── */
.pos-cart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.cart-header h3 {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.cart-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    padding: 30px 16px;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }

.cart-item-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-price {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--amber);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qty-btn {
    width: 24px; height: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.qty-btn:hover { border-color: var(--amber); color: var(--amber); }

.qty-display {
    min-width: 24px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
}

.remove-item {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: var(--transition);
}
.remove-item:hover { color: var(--red); background: rgba(239,68,68,0.1); }

.cart-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
}

.cart-total span:first-child {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.8px;
}

.cart-total span:last-child {
    font-size: 22px;
    font-weight: 700;
    color: var(--amber);
}

/* ─── Receipt ─────────────────────────────────────────── */
.receipt {
    margin-bottom: 16px;
}

.receipt-header {
    text-align: center;
    margin-bottom: 12px;
}

.receipt-header h4 {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--green);
}

/* ─── Login Page ──────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    background-image: repeating-linear-gradient(
        0deg, transparent, transparent 40px,
        rgba(255,255,255,0.015) 40px, rgba(255,255,255,0.015) 41px
    ),
    repeating-linear-gradient(
        90deg, transparent, transparent 40px,
        rgba(255,255,255,0.015) 40px, rgba(255,255,255,0.015) 41px
    );
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-icon { font-size: 40px; display: block; margin-bottom: 10px; }

.login-brand h1 {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: 2px;
}

.login-brand p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: var(--font-mono);
}

.login-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 16px;
    font-family: var(--font-mono);
}
.login-hint code {
    background: var(--bg-surface);
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--text-muted);
}

/* ─── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Language Switcher (sidebar) ────────────────────── */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
    transition: var(--transition);
    text-decoration: none;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}
.lang-switcher:hover {
    border-color: var(--amber);
    color: var(--amber);
}
.lang-flag { font-size: 14px; }

/* ─── Language Switcher (login page) ─────────────────── */
.login-lang {
    text-align: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.login-lang a {
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}
.login-lang a.active {
    color: var(--amber);
    border-color: var(--amber);
    background: var(--amber-glow);
}
.login-lang a:hover:not(.active) {
    color: var(--text);
    border-color: var(--border-light);
}

/* ─── Utility 8XkABnXEYCgUBFAN2oyjC9M4uF1JqisFK9Sf8JpN4Cdr */
.hidden { display: none !important; }

/* =====================================================
   RESPONSIVE — Mobile First
   ===================================================== */

/* ─── Tablet (max 900px) ──────────────────────────────── */
@media (max-width: 900px) {
    .stats-grid       { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid   { grid-template-columns: 1fr; }
    .pos-layout       { grid-template-columns: 1fr; }
}

/* ─── Mobile (max 640px) ──────────────────────────────── */
@media (max-width: 640px) {

    /* Sidebar vira bottom nav */
    :root { --sidebar-w: 0px; }

    .sidebar {
        width: 100%;
        height: 60px;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 200;
    }

    .sidebar-brand  { display: none; }
    .sidebar-footer { display: none; }

    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        padding: 0;
        gap: 0;
        justify-content: space-around;
    }

    .nav-item {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 6px;
        font-size: 10px;
        border-left: none;
        border-top: 3px solid transparent;
        flex: 1;
        text-align: center;
    }

    .nav-item.active {
        border-left: none;
        border-top-color: var(--amber);
    }

    .nav-icon { font-size: 18px; width: auto; }

    /* Main content ocupa tudo + padding bottom para o nav */
    .main-content {
        margin-left: 0;
        padding: 16px 14px 80px 14px;
    }

    /* Header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 16px;
    }

    .page-title { font-size: 17px; }
    .page-date  { font-size: 11px; }

    /* Stats: 2 colunas em mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card  { padding: 14px 12px; gap: 10px; }
    .stat-icon  { font-size: 22px; }
    .stat-value { font-size: 16px; }
    .stat-label { font-size: 10px; }

    /* Dashboard grid: 1 coluna */
    .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }

    /* Quick actions: coluna */
    .quick-actions {
        flex-direction: column;
        gap: 10px;
    }
    .quick-actions .btn { width: 100%; justify-content: center; }

    /* Tabelas: scroll horizontal */
    .card { overflow-x: auto; }

    .table thead th,
    .table tbody td,
    .table tfoot td {
        padding: 9px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Actions cell: stack em coluna */
    .actions-cell {
        flex-direction: column;
        gap: 4px;
    }

    /* Modal: ocupa quase o ecrã todo */
    .modal {
        max-width: 95vw;
        padding: 20px 16px;
        margin: 10px;
    }

    .form-row { grid-template-columns: 1fr; }

    /* Login */
    .login-container { padding: 16px; }
    .login-card      { padding: 28px 20px; }
    .login-brand h1  { font-size: 20px; }

    /* POS */
    .pos-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
        gap: 14px;
    }

    .pos-products {
        height: 380px;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .product-card        { padding: 12px 8px; }
    .product-card-icon   { font-size: 22px; }
    .product-card-name   { font-size: 11px; }
    .product-card-price  { font-size: 12px; }
    .product-card-stock  { font-size: 9px; }

    .pos-cart {
        height: 360px;
    }

    .cart-total span:last-child { font-size: 18px; }

    /* Botões */
    .btn-lg { padding: 12px 16px; font-size: 14px; }
}

/* ─── Mobile pequeno (max 380px) ─────────────────────── */
@media (max-width: 380px) {
    .stats-grid      { grid-template-columns: 1fr 1fr; gap: 8px; }
    .product-grid    { grid-template-columns: repeat(2, 1fr); }
    .stat-value      { font-size: 14px; }
}