/* ==========================================
   CSS SYSTEM DESIGN - POS ROTI AUKHI
   Premium Warm Bakery Theme
   ========================================== */

:root {
    /* Primary Colors (Warm Bakery Palettes) */
    --primary: #d97706; /* Amber 600 */
    --primary-hover: #b45309; /* Amber 700 */
    --primary-dark: #78350f; /* Amber 900 */
    --primary-light: #fef3c7; /* Amber 100 */
    --primary-ultra-light: #fffbeb; /* Amber 50 */
    
    /* Neutrals */
    --bg-base: #fdfaf6; /* Warm soft cream background */
    --bg-panel: #f5eedc; /* Medium warm cream background */
    --bg-card: #ffffff; /* White cards */
    --text-main: #1f2937; /* Dark Gray for readability */
    --text-muted: #6b7280; /* Muted gray text */
    --text-light: #9ca3af;
    --border: #e6dfd3; /* Soft warm border */
    --border-focus: #d97706;
    
    /* Semantic Colors */
    --success: #10b981; /* Emerald green */
    --success-bg: #d1fae5;
    --warning: #f59e0b; /* Orange */
    --warning-bg: #fef3c7;
    --danger: #ef4444; /* Red */
    --danger-bg: #fee2e2;
    --info: #3b82f6; /* Blue */
    --info-bg: #dbeafe;
    
    /* Layout */
    --sidebar-width: 250px;
    --sidebar-bg: #1e110b; /* Dark Chocolate chocolate sidebar */
    --sidebar-text: #fdfaf6;
    --sidebar-text-muted: #a78b7a;
    --sidebar-active: #d97706;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(120, 53, 15, 0.08), 0 4px 6px -2px rgba(120, 53, 15, 0.03);
    --shadow-premium: 0 20px 25px -5px rgba(45, 27, 15, 0.1), 0 10px 10px -5px rgba(45, 27, 15, 0.04);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography Utility */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--primary-dark);
}

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

a:hover {
    color: var(--primary-hover);
}

/* Core SPA View Controllers */
.view-panel {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease-in-out;
}

.view-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   BUTTONS & INPUTS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

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

.btn-outline:hover {
    background-color: var(--primary-ultra-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-logout {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn-logout:hover {
    background-color: var(--danger);
    color: white;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1.05rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-close:hover {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label i {
    width: 14px;
    height: 14px;
}

.form-group input, .form-group select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
    display: flex;
    gap: 12px;
}

.flex-1 {
    flex: 1;
}

/* ==========================================
   VIEW 1: LOGIN PANEL
   ========================================== */
#view-login {
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg-base) 100%);
}

#view-login.active {
    display: flex;
}

.login-card {
    background-color: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    width: 100%;
    max-width: 420px;
    border: 1px solid rgba(217, 119, 6, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    max-height: 90px;
    object-fit: contain;
    margin-bottom: 12px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-role-selector {
    display: flex;
    gap: 12px;
    margin: 20px 0;
}

.role-option {
    flex: 1;
    cursor: pointer;
}

.role-option input {
    display: none;
}

.role-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.role-box i {
    width: 20px;
    height: 20px;
}

.role-option input:checked + .role-box {
    border-color: var(--primary);
    background-color: var(--primary-ultra-light);
    color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ==========================================
   SIDEBAR LAYOUT
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.brand {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    max-height: 55px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.sidebar-nav {
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--sidebar-text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item i {
    width: 18px;
    height: 18px;
}

.nav-item:hover {
    color: var(--sidebar-text);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--sidebar-text);
    background-color: var(--sidebar-active);
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background-color: rgba(255,255,255,0.08);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.user-avatar.admin-avatar {
    color: #e0f2fe;
    background-color: rgba(14, 165, 233, 0.2);
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--sidebar-text-muted);
}

/* ==========================================
   CASHIER VIEW (POS)
   ========================================== */
.cashier-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr 420px;
    min-height: 100vh;
}

.cashier-main {
    margin-left: 0; /* Handled by grid item placing relative to fixed sidebar */
    padding: 24px;
    background-color: var(--bg-base);
    overflow-y: auto;
    height: 100vh;
}

/* Sidebar and main content sit naturally next to each other in grid columns */

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
}

.header-search {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.header-search input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.header-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-online {
    background-color: var(--success-bg);
    color: var(--success);
}

.status-offline {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
}

.datetime {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.datetime i {
    width: 16px;
    height: 16px;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.category-tab {
    padding: 8px 16px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.category-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-tab.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.product-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    user-select: none;
}

.product-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.product-card:active {
    transform: translateY(0);
}

.product-card.out-of-stock {
    opacity: 0.6;
    pointer-events: none;
}

.product-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.product-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 12px;
    line-height: 1.3;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.05rem;
}

.product-stock {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.product-stock.available {
    background-color: var(--success-bg);
    color: var(--success);
}

.product-stock.low {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.product-stock.empty {
    background-color: var(--danger-bg);
    color: var(--danger);
}

/* Checkout Panel (Right Side) */
.checkout-panel {
    background-color: var(--bg-card);
    border-left: 1px solid var(--border);
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.02);
}

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

.checkout-header h3 {
    font-size: 1.1rem;
    color: var(--primary-dark);
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-clear:hover {
    background-color: var(--danger-bg);
}

.customer-info-box {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--primary-ultra-light);
}

.customer-info-box .form-row {
    gap: 8px;
}

.customer-info-box label {
    font-size: 0.75rem;
}

.customer-info-box input {
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.cart-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-cart-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    height: 100%;
    text-align: center;
    gap: 12px;
}

.empty-cart-state i {
    width: 48px;
    height: 48px;
    stroke-width: 1.5;
}

.empty-cart-state p {
    font-size: 0.85rem;
    max-width: 200px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px dotted var(--border);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.cart-item-price {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.btn-qty {
    background-color: var(--bg-card);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: var(--transition);
    color: var(--primary-dark);
}

.btn-qty:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.qty-val {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.cart-item-total {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    min-width: 80px;
    text-align: right;
}

/* Checkout Summary Section */
.checkout-summary {
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--bg-base);
}

.transaction-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.toggle-option {
    flex: 1;
    cursor: pointer;
}

.toggle-option input {
    display: none;
}

.toggle-box {
    display: block;
    text-align: center;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    background-color: var(--bg-card);
    transition: var(--transition);
}

.toggle-option input:checked + .toggle-box {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.font-bold {
    font-weight: 700;
}

.total-row {
    font-size: 1.15rem;
    color: var(--primary-dark);
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-bottom: 16px;
}

.payment-methods {
    margin-bottom: 16px;
}

.payment-methods h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.payment-grid {
    display: flex;
    gap: 6px;
}

.btn-payment {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-payment i {
    width: 18px;
    height: 18px;
}

.btn-payment:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-payment.active {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* Cash Payment Detail Form */
.cash-payment-form {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 16px;
    animation: fadeIn 0.2s ease-in-out;
}

.cash-payment-form .form-group {
    margin-bottom: 8px;
}

.cash-payment-form input {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-align: right;
}

.quick-cash-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.btn-quick-cash {
    flex: 1;
    min-width: 50px;
    padding: 6px;
    background-color: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-quick-cash:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
}

.change-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    font-size: 0.85rem;
}

.change-display strong {
    font-size: 1.1rem;
    color: var(--success);
}

/* ==========================================
   VIEW 3: ADMIN PANEL
   ========================================== */
.admin-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.admin-main {
    padding: 30px;
    background-color: var(--bg-base);
    overflow-y: auto;
    height: 100vh;
}

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

.admin-header h1 {
    font-size: 1.7rem;
    color: var(--primary-dark);
}

.admin-tab-content {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}

.admin-tab-content.active {
    display: block;
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    width: 24px;
    height: 24px;
}

.stat-icon.income {
    background-color: var(--success-bg);
    color: var(--success);
}

.stat-icon.expense {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.stat-icon.profit {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.stat-icon.profit.positive {
    background-color: var(--success-bg);
    color: var(--success);
}

.stat-icon.profit.negative {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.stat-icon.sales {
    background-color: var(--info-bg);
    color: var(--info);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-dark);
}

/* Charts Grid */
.charts-section-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1200px) {
    .charts-section-grid {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.chart-container h3 {
    font-size: 1rem;
    margin-bottom: 20px;
    color: var(--primary-dark);
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Data Tables */
.table-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 30px;
}

.table-header-row {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.table-header-row h3 {
    font-size: 1rem;
}

.responsive-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: var(--primary-ultra-light);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--primary-ultra-light);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.badge-cash {
    background-color: var(--success-bg);
    color: var(--success);
}

.badge-tempo {
    background-color: var(--danger-bg);
    color: var(--danger);
}

/* Bot Simulator Style */
.bot-simulator-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .bot-simulator-grid {
        grid-template-columns: 1fr;
    }
}

.simulator-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chat-window {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.chat-header {
    background-color: #24a1de; /* Telegram blue */
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background-color: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
}

.chat-header span {
    font-size: 0.75rem;
    opacity: 0.8;
    display: block;
}

.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background-color: #e7ebf0; /* Telegram back drop */
}

.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-msg.bot {
    align-self: flex-start;
    background-color: var(--bg-card);
    border-top-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-msg.user {
    align-self: flex-end;
    background-color: #e2f7ff; /* Telegram user blue */
    border-top-right-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-msg.system {
    align-self: center;
    background-color: rgba(0,0,0,0.06);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
    max-width: 90%;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.chat-footer {
    padding: 12px 16px;
    background-color: var(--bg-base);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.chat-footer input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.chat-footer input:focus {
    border-color: var(--primary);
}

.chat-footer button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.explanation {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.explanation h3 {
    font-size: 1.15rem;
    color: var(--primary-dark);
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    list-style: none;
}

.steps-list li {
    display: flex;
    gap: 14px;
}

.step-num {
    width: 28px;
    height: 28px;
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.text-sm {
    font-size: 0.8rem;
}

.quick-templates {
    margin-top: 10px;
    border-top: 1px dashed var(--border);
    padding-top: 16px;
}

.quick-templates h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.quick-templates button {
    margin-right: 6px;
    margin-bottom: 8px;
}

/* ==========================================
   VIEW 4: CUSTOMER DISPLAY LAYOUT
   ========================================== */
.customer-display-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    height: 100vh;
    background-color: var(--bg-base);
}

.customer-left {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e110b 100%);
    color: white;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.customer-brand {
    display: flex;
    align-items: center;
    gap: 20px;
}

.cust-brand-logo {
    max-height: 80px;
    background-color: white;
    padding: 6px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.cust-welcome h2 {
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.cust-welcome p {
    color: var(--sidebar-text-muted);
    font-size: 1.05rem;
}

.cust-media-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px 0;
}

.promo-banner {
    background-color: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    backdrop-filter: blur(10px);
    animation: pulse 4s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.02); }
}

.promo-tag {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.promo-banner h2 {
    color: white;
    font-size: 1.6rem;
    margin-bottom: 10px;
}

.promo-banner p {
    color: var(--sidebar-text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.promo-footer {
    display: block;
    font-size: 0.8rem;
    opacity: 0.6;
}

.customer-right {
    background-color: var(--bg-card);
    padding: 40px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 30px rgba(0,0,0,0.03);
}

.order-summary-header {
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.cust-cart-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cust-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border);
}

.cust-item-desc {
    display: flex;
    flex-direction: column;
}

.cust-item-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
}

.cust-item-qty {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.cust-item-total {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-main);
}

.cust-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    height: 100%;
    gap: 16px;
}

.cust-empty-state i {
    width: 64px;
    height: 64px;
}

.cust-billing-info {
    border-top: 2px solid var(--border);
    padding-top: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.cust-billing-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.05rem;
}

.cust-billing-row.border-top {
    border-top: 1px dashed var(--border);
    padding-top: 12px;
    margin-top: 12px;
}

.cust-billing-row.font-lg {
    font-size: 1.4rem;
    color: var(--primary-dark);
}

.cust-payment-box {
    background-color: var(--primary-ultra-light);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    animation: fadeIn 0.3s ease-in-out;
}

.payment-mirror-info h4 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.payment-mirror-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.payment-mirror-content {
    background-color: white;
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qris-code-image {
    width: 180px;
    height: 180px;
    object-fit: contain;
}

.transfer-info-cust {
    padding: 10px;
    text-align: center;
}

.transfer-bank-name {
    font-weight: 800;
    color: var(--primary-dark);
    font-size: 1.2rem;
}

.transfer-acct-num {
    font-size: 1.4rem;
    letter-spacing: 1px;
    margin: 6px 0;
    color: var(--text-main);
}

/* ==========================================
   MODALS SYSTEM
   ========================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    animation: modalSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.receipt-modal-content {
    max-width: 400px;
}

@keyframes modalSlide {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    font-size: 1.15rem;
}

#product-form, #purchase-form {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background-color: var(--bg-base);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Receipt Print Area Specific Styles */
.receipt-print-wrapper {
    background-color: white;
    padding: 30px 24px;
    color: black;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

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

.receipt-logo {
    max-height: 50px;
    object-fit: contain;
    margin-bottom: 6px;
    filter: grayscale(1);
}

.receipt-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: black;
    letter-spacing: 1px;
}

.receipt-address, .receipt-contact {
    font-size: 0.75rem;
    color: #444;
}

.receipt-divider {
    border: none;
    border-top: 1px dashed #000;
    margin: 12px 0;
}

.receipt-meta p {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.receipt-table {
    width: 100%;
    margin: 12px 0;
    border-collapse: collapse;
}

.receipt-table th {
    background: transparent;
    border-bottom: 1px dashed #000;
    color: black;
    padding: 4px 0;
    font-size: 0.8rem;
}

.receipt-table td {
    padding: 6px 0;
    font-size: 0.8rem;
    border-bottom: none;
}

.receipt-table td:hover {
    background: transparent;
}

.text-right {
    text-align: right;
}

.receipt-totals {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.r-total-row {
    display: flex;
    justify-content: space-between;
}

.receipt-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
}

.receipt-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 16px;
}

.receipt-actions #btn-print-thermal {
    grid-column: span 2;
}

/* Toast System */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background-color: var(--text-main);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.active {
    transform: translateX(0);
}

.toast.success {
    background-color: var(--success);
}

.toast.danger {
    background-color: var(--danger);
}

.toast.warning {
    background-color: var(--warning);
}

.mobile-footer {
    display: none;
    text-align: center;
    padding: 16px 0 8px 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px dotted var(--border);
    margin-top: 20px;
    width: 100%;
}

.mobile-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ==========================================
   RESPONSIVENESS (MOBILE/TABLET)
   ========================================== */

/* Tablet & Smaller Devices (max-width: 1024px) - Convert Sidebar to Top Navigation Bar */
@media (max-width: 1024px) {
    .mobile-footer {
        display: block;
    }

    .cashier-layout {
        grid-template-columns: 1fr;
        height: auto;
        display: flex;
        flex-direction: column;
    }
    
    .admin-layout {
        grid-template-columns: 1fr;
        height: auto;
        display: flex;
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .brand {
        padding: 0;
        border-bottom: none;
    }
    
    .brand-logo {
        max-height: 40px;
    }
    
    .sidebar-nav {
        flex-direction: row;
        padding: 0;
        gap: 8px;
        overflow-x: auto;
        flex: 1;
        margin: 0 16px;
        scrollbar-width: none;
    }
    
    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }
    
    .nav-item {
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    .sidebar-footer {
        padding: 0;
        border-top: none;
    }
    
    .user-info {
        display: none; /* Hide avatar on mobile header to save space */
    }
    
    .cashier-main, .admin-main {
        height: auto;
        padding: 16px;
    }
    
    .checkout-panel {
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

/* Small Screens / Mobile Phone (max-width: 768px) */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .header-search {
        max-width: 100%;
    }
    
    .header-actions {
        justify-content: space-between;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .product-card {
        padding: 12px;
    }
    
    .product-name {
        font-size: 0.85rem;
    }
    
    .product-price {
        font-size: 0.95rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .customer-display-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }
    
    .customer-left {
        padding: 24px;
        min-height: 250px;
    }
    
    .customer-right {
        padding: 24px;
    }
    
    .promo-banner {
        padding: 16px;
    }
}

/* ==========================================
   THERMAL PRINT STYLES
   ========================================== */
@media print {
    /* Hide everything on the page except the receipt print wrapper */
    body * {
        visibility: hidden;
    }
    
    #modal-receipt, 
    #modal-receipt *,
    #receipt-print-area, 
    #receipt-print-area * {
        visibility: visible;
    }
    
    /* Position the printing container exactly at the top-left */
    #modal-receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        display: block !important;
        box-shadow: none;
    }
    
    .modal-content {
        box-shadow: none;
        border: none;
        max-width: 100%;
        width: 100%;
        background: transparent;
    }
    
    #receipt-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm; /* Standard receipt width, can adjust to 58mm in print page settings */
        padding: 0;
        margin: 0;
        font-family: 'Courier New', Courier, monospace;
        font-size: 9pt;
    }
    
    .no-print {
        display: none !important;
    }
}
