/* General Styling */
:root {
    --primary-color: #4CAF50; /* Green */
    --secondary-color: #f44336; /* Red */
    --accent-color: #2196F3; /* Blue */
    --text-color: #333;
    --bg-color: #f0f2f5;
    --card-bg: #fff;
    --border-color: #ddd;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --button-hover: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* POS Container */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Default: 2 columns for desktop */
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    flex-grow: 1; /* Allow container to take available space */
}

/* Admin Dashboard Toggle */
.admin-access {
    grid-column: 1 / -1; /* Spans across all columns */
    text-align: right;
    margin-bottom: 10px;
}

.admin-btn {
    background-color: #607D8B; /* Grey for admin button */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.admin-btn:hover {
    background-color: #455A64;
}

/* Hide admin section by default on smaller screens/initial load */
.pos-container.hide-admin .admin-hidden {
    display: none;
}

/* Admin visible state - for 3-column layout */
body.admin-visible .pos-container {
    grid-template-columns: 1fr 1fr 1fr; /* 3 columns when admin is visible */
}

body.admin-visible .pos-container .terminal-section:nth-child(2) { /* Targeting cart/transaction section */
    grid-column: auto; /* Ensure it stays in its column */
}

/* Terminal Sections */
.terminal-section {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.section-icon {
    font-size: 1.8rem;
}

.section-title {
    font-size: 1.6rem;
    color: var(--primary-color);
    flex-grow: 1;
}

/* Menu Categories */
.menu-categories {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 10px;
    margin-bottom: 15px;
}

.category-btn {
    background-color: #e0e0e0;
    color: var(--text-color);
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease, transform 0.1s ease;
    flex-grow: 1; /* Allow buttons to grow */
    min-width: 80px; /* Minimum width for buttons */
}

.category-btn:hover {
    background-color: #ccc;
}

.category-btn.active {
    background-color: var(--accent-color);
    color: white;
}

/* Menu Items */
.menu-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Responsive grid */
    gap: 15px;
    flex-grow: 1;
    overflow-y: auto; /* Scroll for many items */
    padding-right: 5px; /* For scrollbar space */
}

.menu-item {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Pushes price to bottom */
}

.menu-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.item-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.item-description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
    flex-grow: 1; /* Allows description to take space */
}

.item-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-color);
    text-align: right;
}

/* Cart Items */
.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-name {
    font-weight: bold;
    font-size: 1rem;
}

.cart-item-price {
    font-size: 0.85rem;
    color: #777;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.qty-btn {
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    min-width: 35px; /* Ensure buttons are clickable */
    text-align: center;
}

.qty-btn:hover {
    background-color: #ddd;
}

.quantity {
    font-weight: bold;
    min-width: 25px;
    text-align: center;
}

.remove-item {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--secondary-color);
    margin-left: 5px;
}

/* Cart Total */
.cart-total {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: 15px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 1rem;
}

.total-row.final {
    font-weight: bold;
    font-size: 1.3rem;
    color: var(--primary-color);
}

/* Form Styling */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-color);
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.confirm-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    width: 100%;
    transition: background-color 0.3s ease;
}

.confirm-btn:hover:not(:disabled) {
    background-color: #43A047; /* Darker green */
}

.confirm-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Transaction Summary */
.summary-display {
    background-color: #e8f5e9; /* Light green background */
    border: 1px solid #a5d6a7; /* Darker green border */
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    opacity: 0; /* Hidden by default */
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    visibility: hidden; /* Prevent interaction when hidden */
}

.summary-display.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.summary-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 1rem;
}

.summary-label {
    font-weight: bold;
    color: #555;
}

.summary-value {
    color: var(--text-color);
}

.summary-value.points-earned {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.1rem;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 30px 10px;
    color: #888;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.4;
}

.empty-state.error {
    color: var(--secondary-color);
}

/* Admin Dashboard Controls */
.dashboard-controls {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    gap: 10px;
    margin-bottom: 15px;
}

.control-btn {
    background-color: var(--accent-color);
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    flex-grow: 1;
}

.control-btn:hover {
    background-color: #1976D2; /* Darker blue */
}

.control-btn.clear-btn {
    background-color: var(--secondary-color);
}

.control-btn.clear-btn:hover {
    background-color: #D32F2F; /* Darker red */
}

/* Customer List */
.customers-list {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.customer-card {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.customer-phone {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.customer-points {
    display: flex;
    align-items: center;
    gap: 10px;
}

.points-badge {
    background-color: var(--accent-color);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 0.95rem;
}

.remove-customer {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--secondary-color);
}

/* Status Bar */
.status-bar {
    background-color: #333;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 0.9rem;
    border-top: 3px solid var(--primary-color);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-value {
    font-weight: bold;
    color: #FFEB3B; /* Yellowish for values */
}


/* --- RESPONSIVE DESIGN (MEDIA QUERIES) --- */

/* For screens smaller than 1024px (e.g., large tablets, smaller laptops) */
@media (max-width: 1024px) {
    .pos-container {
        padding: 15px;
        gap: 15px;
        grid-template-columns: 1fr; /* Default to 1 column for these devices */
    }

    body.admin-visible .pos-container {
        grid-template-columns: 1fr; /* Keep 1 column even if admin is visible */
    }

    /* Adjust order for better flow on smaller screens */
    .terminal-section:nth-child(1) { order: 1; } /* Menu */
    .terminal-section:nth-child(2) { order: 2; } /* Cart */
    .terminal-section:nth-child(3) { order: 3; } /* Admin */

    .menu-items {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Smaller menu items */
    }

    .category-btn {
        padding: 7px 12px;
        font-size: 0.85rem;
    }

    .status-bar {
        font-size: 0.8rem;
        padding: 10px 15px;
        flex-wrap: wrap; /* Allow items to wrap */
        justify-content: center;
        gap: 10px;
    }
    
    .status-item {
        margin: 5px 0; /* Add some vertical spacing */
    }

    .section-title {
        font-size: 1.4rem;
    }
}


/* For screens smaller than 768px (e.g., most tablets in portrait, large phones) */
@media (max-width: 768px) {
    .pos-container {
        padding: 10px;
        gap: 10px;
    }

    .terminal-section {
        padding: 15px;
    }

    .section-icon {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.3rem;
    }

    .menu-items {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* Even smaller menu items */
    }

    .menu-item {
        padding: 10px;
    }

    .item-name {
        font-size: 1rem;
    }
    .item-description {
        font-size: 0.75rem;
    }
    .item-price {
        font-size: 1.0rem; /* Adjusted slightly to keep it prominent */
    }

    .cart-item {
        flex-direction: column; /* Stack info and controls */
        align-items: flex-start;
        gap: 5px;
        padding: 8px;
    }

    .cart-item-info { /* Ensure info takes full width when stacked */
        width: 100%;
    }

    .quantity-controls {
        width: 100%;
        justify-content: space-around;
    }

    .qty-btn {
        padding: 4px 8px;
        min-width: 30px;
    }

    .remove-item {
        font-size: 1rem;
        margin-left: auto; /* Push remove button to the right when stacked */
    }
    
    .cart-total {
        padding-top: 10px;
        margin-top: 10px;
    }

    .total-row {
        font-size: 0.95rem;
    }

    .total-row.final {
        font-size: 1.2rem;
    }

    .form-input, .confirm-btn {
        padding: 10px;
        font-size: 1rem;
    }

    .summary-display {
        padding: 10px;
    }
    .summary-title {
        font-size: 1.2rem;
    }
    .summary-item {
        font-size: 0.9rem;
    }
    .summary-value.points-earned {
        font-size: 1rem;
    }

    .dashboard-controls {
        flex-direction: column; /* Stack control buttons */
    }

    .control-btn {
        width: 100%;
        padding: 10px;
    }

    .customer-card {
        flex-direction: column; /* Stack customer info */
        align-items: flex-start;
        padding: 10px;
    }

    .customer-phone {
        margin-bottom: 5px; /* Add space between phone and points */
    }

    .customer-points {
        width: 100%;
        justify-content: space-between;
        margin-top: 5px;
    }

    .remove-customer {
        margin-left: 0; /* Reset margin for stacked layout */
    }

    .status-bar {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
    }

    .status-item {
        width: 100%;
        justify-content: space-between; /* Space out label and value */
        margin-bottom: 5px;
    }
}


/* For very small screens (e.g., older phones, very narrow viewports) */
@media (max-width: 480px) {
    .menu-items {
        grid-template-columns: 1fr; /* Single column for menu items */
    }

    .menu-item {
        padding: 12px; /* Slightly more padding for single column items */
    }

    .category-btn {
        flex-grow: 1; /* Make categories fill width */
        min-width: unset;
    }
}