/* Macra POS - core stylesheet
   Corporate colors derived from the Macra logo. No gradients, no thick borders. */

:root {
    --primary: #132d5e;
    --primary-dark: #0c1f42;
    --primary-light: #1e3f7d;
    --accent: #e34c03;
    --accent-dark: #c04102;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --border: #e0e4ec;
    --text: #202531;
    --text-muted: #6b7280;
    --success: #1a7a3d;
    --warning: #b8860b;
    --danger: #c0392b;
    --radius: 8px;
    --sidebar-width: 230px;
    --header-height: 60px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
}

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

img { max-width: 100%; }

/* Layout */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 40;
    transition: left 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-brand img { height: 32px; width: auto; }

.sidebar-brand span {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.3px;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.82);
    padding: 11px 18px;
    font-size: 13.5px;
    border-left: 3px solid transparent;
}

.sidebar-nav a i { width: 18px; text-align: center; color: rgba(255,255,255,0.65); }

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.09);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-nav a.active i { color: var(--accent); }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-section-label {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.6px;
    color: rgba(255,255,255,0.45);
    padding: 14px 18px 4px;
}

.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.topbar {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--primary);
    cursor: pointer;
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 18px; }

.topbar-badge {
    position: relative;
    color: var(--text-muted);
    font-size: 18px;
}

.topbar-badge .count {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    border-radius: 8px;
    padding: 0 5px;
    font-weight: 700;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
}

.user-chip .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.content {
    padding: 22px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h1 {
    font-size: 20px;
    margin: 0;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    line-height: 1.2;
}

.btn:hover { opacity: 0.92; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--primary); }
.btn-outline:hover { border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.card + .card { margin-top: 16px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

.stat-icon.accent { background: var(--accent); }
.stat-icon.success { background: var(--success); }
.stat-icon.warning { background: var(--warning); }

.stat-label { font-size: 12px; color: var(--text-muted); margin: 0 0 2px; }
.stat-value { font-size: 19px; font-weight: 700; color: var(--text); margin: 0; }

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

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

table.data-table th {
    text-align: left;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

table.data-table tr:hover td { background: #fafbfd; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 34px; margin-bottom: 10px; color: var(--border); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-success { background: #e5f3ea; color: var(--success); }
.badge-warning { background: #fbf1de; color: var(--warning); }
.badge-danger { background: #fbe9e6; color: var(--danger); }
.badge-neutral { background: #eef0f4; color: var(--text-muted); }
.badge-primary { background: #e7ebf3; color: var(--primary); }

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

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    background: var(--surface);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

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

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

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* Alerts */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.alert-success { background: #e5f3ea; color: var(--success); border-color: #c9e6d2; }
.alert-danger { background: #fbe9e6; color: var(--danger); border-color: #f3c9c1; }
.alert-warning { background: #fbf1de; color: var(--warning); border-color: #f0dfae; }
.alert-info { background: #e7ebf3; color: var(--primary); border-color: #cdd6e8; }

/* Login / register screens */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 34px 32px;
    width: 100%;
    max-width: 400px;
}

.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo img { height: 56px; }
.auth-logo h1 { font-size: 18px; color: var(--primary); margin: 10px 0 0; }
.auth-logo p { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }

.auth-footer { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--text-muted); }

/* POS screen */
.pos-layout {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    align-items: start;
}

.pos-scan {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.pos-scan .form-control { font-size: 15px; padding: 12px; }

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

.product-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    text-align: left;
}

.product-tile:hover { border-color: var(--accent); }

.product-tile .p-name { font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.product-tile .p-price { color: var(--accent); font-weight: 700; font-size: 14px; margin: 0; }
.product-tile .p-stock { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.cart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 76px;
}

.cart-items { max-height: 320px; overflow-y: auto; margin-bottom: 12px; }

.cart-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.cart-row .ci-name { flex: 1; font-size: 12.5px; min-width: 0; }
.cart-row .ci-name small { display: block; color: var(--text-muted); }
.cart-row input.qty {
    width: 40px;
    padding: 5px 3px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.cart-row .ci-remove { color: var(--danger); cursor: pointer; background: none; border: none; }

.cart-totals { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.cart-totals .row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.cart-totals .row.total { font-size: 16px; font-weight: 700; color: var(--primary); }

/* Modals */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 18, 32, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px;
}

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

.modal-header h3 { margin: 0; font-size: 16px; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }

/* Receipt */
.receipt {
    max-width: 320px;
    margin: 0 auto;
    background: #fff;
    padding: 18px;
    font-family: 'Courier New', monospace;
    font-size: 12.5px;
}

.receipt h2 { text-align: center; margin: 0 0 4px; font-size: 15px; }
.receipt .center { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.receipt table td { padding: 2px 0; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { left: -230px; }
    .sidebar.open { left: 0; }
    .main-area { margin-left: 0; width: 100%; }
    .hamburger { display: block; }
    .pos-layout { grid-template-columns: 1fr; }
    .cart-panel { position: static; }
}
