/* ============ Confectionery Billing - Responsive UI ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #e91e63;
    --primary-dark: #ad1457;
    --secondary: #ff9800;
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
    --dark: #2c3e50;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f4f6f9;
    color: #333;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s;
}
.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}
.logo-circle {
    width: 44px; height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.shop-name { font-weight: 600; font-size: 14px; }
.user-info { font-size: 12px; opacity: 0.7; }
.close-sidebar {
    background: transparent; border: none; color: #fff;
    font-size: 20px; cursor: pointer; display: none;
    position: absolute; right: 10px; top: 15px;
}

.sidebar-nav { padding: 12px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar-nav a i { font-size: 18px; width: 22px; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-nav a.active {
    background: rgba(233,30,99,0.15);
    color: #fff;
    border-left-color: var(--primary);
}
.logout-link { margin-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); }

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    min-height: 100vh;
}

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 999;
}
.mobile-topbar { display: none; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .close-sidebar { display: block; }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; padding: 12px; padding-top: 70px; }
    
    .mobile-topbar {
        display: flex; align-items: center;
        position: fixed; top: 0; left: 0; right: 0;
        background: var(--primary); color: #fff;
        padding: 12px 16px;
        z-index: 998;
        box-shadow: var(--shadow);
    }
    .hamburger {
        background: transparent; border: none; color: #fff;
        font-size: 24px; cursor: pointer; padding: 0;
    }
    .mobile-logo { flex: 1; text-align: center; font-weight: 600; }
    .mobile-bill-btn {
        background: rgba(255,255,255,0.2);
        color: #fff;
        width: 38px; height: 38px;
        border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        text-decoration: none;
    }
}

/* ===== Components ===== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 600; color: var(--dark); }

.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin: -20px -20px 20px -20px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 16px;
    border-left: 4px solid var(--primary);
}
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--info); }
.stat-icon {
    width: 50px; height: 50px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(233,30,99,0.1); color: var(--primary);
    font-size: 24px;
}
.stat-card.success .stat-icon { background: rgba(76,175,80,0.1); color: var(--success); }
.stat-card.warning .stat-icon { background: rgba(255,152,0,0.1); color: var(--warning); }
.stat-card.info .stat-icon { background: rgba(33,150,243,0.1); color: var(--info); }
.stat-label { font-size: 12px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--dark); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: var(--dark); }
.form-control, .form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    transition: border 0.2s;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233,30,99,0.1);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-secondary { background: var(--gray); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--dark); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* Tables */
.table-wrap { background: #fff; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 0.5px;
}
.table tbody tr:hover { background: #fafbfc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
}
.badge-success { background: rgba(76,175,80,0.15); color: var(--success); }
.badge-warning { background: rgba(255,152,0,0.15); color: var(--warning); }
.badge-danger { background: rgba(244,67,54,0.15); color: var(--danger); }
.badge-info { background: rgba(33,150,243,0.15); color: var(--info); }

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    position: relative;
    font-size: 14px;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.close-alert { position: absolute; right: 14px; top: 12px; cursor: pointer; font-size: 22px; line-height: 1; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 10px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; line-height: 1; }

/* ===== Login Page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    padding: 40px 32px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 400px;
}
.login-logo {
    text-align: center; margin-bottom: 24px;
}
.login-logo .icon {
    width: 70px; height: 70px;
    background: var(--primary); color: #fff;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 32px; margin-bottom: 12px;
}
.login-logo h2 { color: var(--dark); font-size: 22px; }
.login-logo p { color: var(--gray); font-size: 14px; margin-top: 4px; }

/* ===== Billing/POS Page ===== */
.pos-wrapper {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 20px;
    height: calc(100vh - 80px);
}
@media (max-width: 1024px) {
    .pos-wrapper { grid-template-columns: 1fr; height: auto; }
}

.pos-products {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.pos-cart {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.product-search {
    display: flex; gap: 8px; margin-bottom: 16px;
}
.product-search input { flex: 1; }
.scan-btn {
    background: var(--info); color: #fff;
    border: none; padding: 0 14px; border-radius: 6px;
    cursor: pointer;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.product-tile {
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.product-tile:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.product-tile .name { font-size: 13px; font-weight: 500; margin-bottom: 4px; min-height: 36px; }
.product-tile .price { color: var(--primary); font-weight: 700; font-size: 15px; }
.product-tile .code { font-size: 10px; color: var(--gray); }
.product-tile .stock { font-size: 11px; color: var(--success); margin-top: 4px; }
.product-tile.low-stock .stock { color: var(--warning); }
.product-tile.no-stock { opacity: 0.5; cursor: not-allowed; }

.cart-header { font-weight: 600; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; display: flex; justify-content: space-between; }
.cart-customer { margin-bottom: 12px; padding: 10px; background: #f8f9fa; border-radius: 6px; }
.cart-items { flex: 1; overflow-y: auto; margin-bottom: 12px; max-height: 350px; }
.cart-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #eee;
}
.cart-item .name { font-size: 13px; font-weight: 500; }
.cart-item .meta { font-size: 11px; color: var(--gray); }
.cart-item .controls { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.qty-btn {
    background: #f0f0f0; border: none; width: 26px; height: 26px;
    border-radius: 4px; cursor: pointer; font-weight: bold;
}
.qty-input {
    width: 50px; text-align: center;
    border: 1px solid var(--border); border-radius: 4px;
    padding: 3px;
    font-size: 13px;
}
.price-input {
    width: 70px; text-align: right;
    border: 1px solid var(--border); border-radius: 4px;
    padding: 3px 6px;
    font-size: 13px;
}
.remove-btn { background: var(--danger); color: #fff; border: none; padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; }

.cart-summary {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.summary-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; font-size: 14px;
}
.summary-row.total {
    font-size: 18px; font-weight: 700;
    border-top: 1px solid var(--border);
    margin-top: 6px; padding-top: 10px;
    color: var(--primary);
}

/* Toast */
.toast {
    position: fixed; bottom: 20px; right: 20px;
    background: var(--dark); color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    z-index: 3000;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.flex-1 { flex: 1; }

/* Print only - thermal printer */
@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .sidebar, .mobile-topbar, .main-content { margin: 0; padding: 0; }
    .app-wrapper { display: block; }
}
