:root {
    --primary-color: #2c3e50;
    --secondary-color: #e74c3c;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --text-color: #ecf0f1;
    --bg-color: #34495e;
    --card-bg: #2c3e50;
    --sidebar-bg: #22313f;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

/* Screen Management */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
}

/* Login Screen */
#loginScreen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7b2ff7, #1e90ff);
}

.login-container {
    background: rgba(0, 0, 0, 0.6);
    padding: 3rem;
    border-radius: var(--border-radius);
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.login-container h1 {
    margin-bottom: 2rem;
    font-size: 2.5rem;
    color: white;
}
.brand-logo {
    width: 120px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.pin-btn {
    padding: 20px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.pin-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#pinDisplay {
    width: 100%;
    padding: 15px;
    font-size: 2rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    margin-bottom: 10px;
    border-radius: 5px;
}

/* Main Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header {
    margin-bottom: 30px;
    text-align: center;
}
.brand-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
}
.brand-logo.brand-small {
    width: 40px;
    height: 40px;
    margin: 0;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.settings-hero {
    width: 180px;
    height: auto;
    display: block;
    margin: 0 auto 10px auto;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

.nav-btn {
    padding: 15px;
    margin-bottom: 10px;
    background: transparent;
    border: none;
    color: #bdc3c7;
    text-align: left;
    cursor: pointer;
    font-size: 1.1rem;
    border-radius: 5px;
    transition: all 0.2s;
    width: 100%;
}

.nav-btn:hover, .nav-btn.active {
    background-color: var(--accent-color);
    color: white;
}

.user-profile {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logout-btn {
    background: var(--secondary-color);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.main-area {
    flex: 1;
    position: relative;
    background-color: #2c3e50;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Floor Plan Editor (Canvas) */
#floorPlanCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
    overflow: hidden;
}

.table-element {
    position: absolute;
    background-color: #95a5a6;
    border: 2px solid #7f8c8d;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    user-select: none;
    transition: transform 0.1s, border-color 0.2s;
    color: #2c3e50;
}

.table-element:hover {
    transform: scale(1.02);
}

.table-element.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}
.table-element.ready-alert {
    animation: readyPulse 1s infinite;
    box-shadow: 0 0 12px #27ae60;
}
.table-logo-overlay {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    pointer-events: none;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.table-element.occupied {
    background-color: var(--secondary-color);
    border-color: #c0392b;
    color: white;
}

.table-element.available {
    background-color: var(--success-color);
    border-color: #27ae60;
    color: white;
}

.table-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.table-info {
    font-size: 0.8rem;
    margin-top: 5px;
}

.table-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--warning-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.table-badge.ready {
    background: var(--success-color);
}
@keyframes readyPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Editor Toolbar */
.editor-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--sidebar-bg);
    padding: 10px 20px;
    border-radius: 30px;
    display: flex;
    gap: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 100;
}

.tool-btn {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--accent-color);
    transform: translateY(-5px);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal.full-screen {
    align-items: flex-start;
    padding-top: 20px;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-content.full-height {
    height: 95vh;
    max-height: 95vh;
    width: 95%;
    max-width: 1400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: white;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #bdc3c7;
}

.form-control {
    width: 100%;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    border-radius: 5px;
}

.form-control option {
    background-color: var(--card-bg);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-primary { background: var(--accent-color); color: white; }
.btn-success { background: var(--success-color); color: white; }
.btn-danger { background: var(--secondary-color); color: white; }
.btn-warning { background: var(--warning-color); color: white; }
.btn-info { background: #17a2b8; color: white; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,0.3); color: white; }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: white; }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.2rem; padding: 15px; }

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    color: white;
}

/* Lists */
.list-group {
    list-style: none;
}

.list-item {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Admin Panel */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
    height: 100%;
}

.admin-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.admin-card h3 {
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

/* Order Interface (Modal) */
.order-layout {
    display: flex;
    height: 60vh;
    gap: 20px;
}

.menu-section {
    flex: 2;
    overflow-y: auto;
    padding-right: 10px;
}

.cart-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 15px;
}

.menu-categories {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.category-btn {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.category-btn.active, .category-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.menu-item-card {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.menu-item-card:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.item-price {
    color: var(--success-color);
    font-weight: bold;
    margin-top: 5px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
}

.cart-total {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: right;
    margin-bottom: 15px;
    padding-top: 10px;
    border-top: 2px solid rgba(255,255,255,0.1);
}

/* Existing Orders in Cart */
.existing-orders {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px dashed rgba(255,255,255,0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.existing-orders-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 10px;
    background: rgba(0,0,0,0.1);
}

.existing-order-item {
    background: rgba(255,255,255,0.05);
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    border-left: 3px solid var(--accent-color);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.order-items-list {
    font-size: 0.85rem;
    color: #bdc3c7;
    margin-bottom: 5px;
}

.order-total {
    text-align: right;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    background: #7f8c8d;
}

.badge-new { background: var(--accent-color); }
.badge-cooking { background: var(--warning-color); }
.badge-ready { background: var(--success-color); }
.badge-served { background: #95a5a6; }

/* Kitchen Grid */
.kitchen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
}

.kitchen-ticket {
    background: var(--card-bg);
    border-left: 5px solid var(--accent-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
}

.kitchen-ticket.cooking { border-left-color: var(--warning-color); }
.kitchen-ticket.ready { border-left-color: var(--success-color); }
.kitchen-ticket.served { border-left-color: #95a5a6; opacity: 0.7; }

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

.ticket-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px dashed rgba(255,255,255,0.2);
    padding-bottom: 10px;
}

.ticket-header h3 {
    font-size: 1.2rem;
}

.ticket-time {
    color: #95a5a6;
    font-size: 0.9rem;
}

.ticket-meta {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.ticket-items {
    flex: 1;
    margin-bottom: 15px;
}

.ticket-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.ticket-item .qty {
    font-weight: bold;
    margin-right: 10px;
    color: var(--accent-color);
}

.ticket-actions {
    margin-top: auto;
}

/* Data Tables */
.menu-table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.data-table th, .data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.data-table th {
    background: rgba(0,0,0,0.2);
    font-weight: bold;
}

.data-table tr:hover {
    background: rgba(255,255,255,0.05);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-style: italic;
    grid-column: 1 / -1;
}

/* Discount Grid */
.discount-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.discount-btn {
    padding: 15px;
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.discount-btn:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

/* Price Pad */
.price-display-container {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: right;
}

.price-input-display {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--success-color);
}

.price-pad {
    grid-template-columns: repeat(3, 1fr);
}

/* --- Payment / Checkout Styles --- */
.payment-layout {
    display: flex;
    flex-direction: row;
    height: 70vh;
    gap: 20px;
}

.payment-receipt {
    flex: 1;
    background: #fff;
    color: #333; /* Receipt is usually black on white */
    padding: 20px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace; /* Receipt font */
}

.receipt-header {
    text-align: center;
    border-bottom: 1px dashed #333;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.receipt-items {
    flex: 1;
    overflow-y: auto;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.receipt-footer {
    border-top: 1px dashed #333;
    padding-top: 10px;
    margin-top: 10px;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.receipt-total-row {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 1.2rem;
    margin-top: 10px;
}

.payment-controls {
    flex: 1.2;
    display: flex;
    flex-direction: column;
}

.payment-display {
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.pay-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.pay-row.large {
    font-size: 1.5rem;
    font-weight: bold;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 10px;
    margin-top: 10px;
}

.pay-amount {
    color: var(--accent-color);
}

.pay-received {
    color: var(--warning-color);
}

.pay-change {
    color: var(--success-color);
}

.payment-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    flex: 1;
}

.payment-keypad .pin-btn {
    padding: 15px;
    font-size: 1.5rem;
}

.quick-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.quick-btn {
    padding: 15px;
    background: #7f8c8d;
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    font-weight: bold;
}

.quick-btn:hover {
    background: #95a5a6;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    /* Main Layout */
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 10px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        overflow-x: auto;
        white-space: nowrap;
    }

    .sidebar-header {
        margin-bottom: 0;
        margin-right: 15px;
    }

    .sidebar-header h2 {
        font-size: 1.2rem;
        margin: 0;
    }

    #navList {
        display: flex;
        gap: 10px;
        flex: 1;
    }

    .nav-btn {
        margin-bottom: 0;
        padding: 8px 15px;
        font-size: 0.9rem;
        width: auto;
        flex-shrink: 0;
    }

    .user-profile {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        margin-left: 10px;
        padding-left: 10px;
        border-left: 1px solid rgba(255,255,255,0.1);
    }
    
    #userNameDisplay, #userRoleDisplay {
        display: none; /* Hide user name on mobile to save space */
    }

    .logout-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        padding: 15px;
        max-height: 95vh;
    }

    .modal-content.full-height {
        height: 100vh;
        width: 100%;
        border-radius: 0;
    }

    .order-layout {
        flex-direction: column;
        height: auto;
    }

    .menu-section {
        flex: 1;
        max-height: 50vh;
        padding-right: 0;
    }

    .cart-section {
        flex: 1;
        max-height: 40vh;
        margin-top: 10px;
    }
    
    .menu-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .menu-item-card {
        padding: 10px;
    }
    
    .item-name {
        font-size: 0.9rem;
    }

    /* Kitchen View */
    .kitchen-grid {
        grid-template-columns: 1fr;
    }

    /* Pin Pad */
    .pin-pad {
        gap: 5px;
    }
    
    .pin-btn {
        padding: 15px;
        font-size: 1.2rem;
    }

    /* Tables */
    .table-element {
        transform: scale(0.8); /* Slightly smaller tables visually if needed, but keeping logic same */
    }
    
    /* Editor Toolbar */
    .editor-toolbar {
        width: 90%;
        justify-content: space-around;
        bottom: 10px;
    }

    /* Payment Modal Mobile */
    .payment-layout {
        flex-direction: column;
        height: auto;
    }
    .payment-receipt {
        max-height: 300px;
        margin-bottom: 10px;
    }
    .payment-keypad {
        gap: 5px;
    }
    .quick-amounts {
        gap: 5px;
    }
    .pay-row {
        font-size: 1rem;
    }

/* --- Order Details & Discount Controls --- */
.order-items-detail {
    list-style: none;
    padding: 0;
    margin: 5px 0 10px 0;
    border-top: 1px solid #eee;
}

.order-items-detail li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

.item-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.item-note {
    font-size: 0.8rem;
    color: #e67e22;
    font-style: italic;
    margin-top: 2px;
}

.item-controls {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    justify-content: flex-end;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 0.75rem;
    border-radius: 3px;
    cursor: pointer;
    border: none;
    color: white;
}

.btn-info {
    background-color: #3498db;
}
}
