/**
 * Shared UI Styles
 * Used by both POS and Website
 * 
 * Includes: Menu UI, Postcode Lookup, Delivery Slots
 */

/* ===========================================
   POSTCODE LOOKUP STYLES
   =========================================== */
.postcode-lookup-container {
    margin-bottom: 20px;
}

.postcode-input-row {
    display: flex;
    gap: 10px;
}

.postcode-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--menu-border, #ddd);
    border-radius: 8px;
    text-transform: uppercase;
}

.postcode-input:focus {
    border-color: var(--menu-primary, #1976d2);
    outline: none;
}

.postcode-lookup-btn {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    background: var(--menu-primary, #1976d2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.postcode-lookup-btn:hover {
    opacity: 0.9;
}

.postcode-lookup-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.postcode-result {
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
}

.postcode-result .success {
    color: #2e7d32;
    background: #e8f5e9;
    padding: 10px 15px;
    border-radius: 6px;
    display: block;
}

.postcode-result .error {
    color: #c62828;
    background: #ffebee;
    padding: 10px 15px;
    border-radius: 6px;
    display: block;
}

.postcode-result .loading {
    color: #666;
}

.address-fields .form-group {
    margin-bottom: 15px;
}

.address-fields label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--menu-text, #333);
}

.address-fields input {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    border: 2px solid var(--menu-border, #ddd);
    border-radius: 6px;
}

.address-fields input:focus {
    border-color: var(--menu-primary, #1976d2);
    outline: none;
}

.address-fields input[readonly] {
    background: #f5f5f5;
    color: #666;
}

/* ===========================================
   DELIVERY SLOT PICKER STYLES
   =========================================== */
.slot-picker-container {
    margin: 20px 0;
}

.slot-picker-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.slot-picker-tab {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid var(--menu-border, #ddd);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
}

.slot-picker-tab.active {
    background: var(--menu-primary, #1976d2);
    color: white;
    border-color: var(--menu-primary, #1976d2);
}

.slot-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .slot-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.slot-item {
    padding: 10px 8px;
    font-size: 14px;
    text-align: center;
    border: 2px solid var(--menu-border, #ddd);
    border-radius: 6px;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}

.slot-item:hover:not(.full):not(.disabled) {
    border-color: var(--menu-primary, #1976d2);
    background: var(--menu-primary-light, rgba(25, 118, 210, 0.1));
}

.slot-item.selected {
    background: var(--menu-primary, #1976d2);
    color: white;
    border-color: var(--menu-primary, #1976d2);
}

.slot-item.full {
    background: #ffebee;
    color: #999;
    cursor: not-allowed;
    text-decoration: line-through;
}

.slot-item.disabled {
    background: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
}

.slot-item .slot-time {
    font-weight: bold;
}

.slot-item .slot-capacity {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.slot-item.selected .slot-capacity {
    color: rgba(255,255,255,0.8);
}

/* ===========================================
   MENU UI STYLES
   =========================================== */

/**
 * Shared Menu UI Styles
 * Used by both POS (register.php) and Website (menu.php)
 * 
 * Uses CSS variables with fallbacks so each app can customize colors
 * Location: /var/www/html/shared_libs/menu-ui.css
 */

/* ========================================
   CSS Variable Defaults (can be overridden)
   ======================================== */
:root {
    --menu-primary: #1976d2;
    --menu-primary-light: rgba(25, 118, 210, 0.1);
    --menu-border: #ddd;
    --menu-border-hover: var(--menu-primary);
    --menu-text: #333;
    --menu-text-muted: #666;
    --menu-bg: white;
    --menu-bg-selected: #e3f2fd;
    --menu-required: #d32f2f;
}

/* ========================================
   Option Grid Layout - 3 columns
   ======================================== */
.option-grid,
.checkbox-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* ========================================
   Option Item (Radio buttons)
   ======================================== */
.option-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border: 2px solid var(--menu-border, #ddd);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    background: var(--menu-bg, white);
    min-height: 50px;
}

.option-item:hover {
    border-color: var(--menu-border-hover, var(--menu-primary, #1976d2));
    background: var(--menu-primary-light, rgba(25, 118, 210, 0.05));
}

.option-item.selected {
    border-color: var(--menu-primary, #1976d2);
    background: var(--menu-bg-selected, #e3f2fd);
}

.option-item input[type="radio"],
.option-item-radio {
    display: none;
}

/* ========================================
   Checkbox Option (Multi-select)
   ======================================== */
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--menu-border, #ddd);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--menu-bg, white);
}

.checkbox-option:hover {
    border-color: var(--menu-border-hover, var(--menu-primary, #1976d2));
}

.checkbox-option.selected {
    border-color: var(--menu-primary, #1976d2);
    background: var(--menu-bg-selected, rgba(25, 118, 210, 0.08));
}

.checkbox-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--menu-primary, #1976d2);
    flex-shrink: 0;
    cursor: pointer;
}

.checkbox-option .option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

/* ========================================
   Option Text Styling
   ======================================== */
.option-name,
.option-item-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--menu-text, #333);
}

.option-price,
.option-item-price,
.option-item-extra {
    font-size: 12px;
    color: var(--menu-text-muted, #666);
    margin-top: 2px;
}

/* ========================================
   Option Section Container
   ======================================== */
.option-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.option-section h4,
.option-section-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--menu-text-muted, #666);
    text-transform: uppercase;
}

/* Multi-select hint */
.option-section[data-multi="true"] h4::after {
    content: ' (select multiple)';
    font-size: 11px;
    font-weight: normal;
    color: #888;
    font-style: italic;
    text-transform: none;
}

/* ========================================
   Required Indicators
   ======================================== */
.required-star,
.required-marker {
    color: var(--menu-required, #d32f2f);
    font-weight: 600;
}

/* ========================================
   Quantity Controls
   ======================================== */
.quantity-controls,
.item-quantity-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-btn,
.qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--menu-border, #ddd);
    border-radius: 6px;
    background: var(--menu-bg, white);
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.quantity-btn:hover,
.qty-btn:hover {
    background: var(--menu-primary, #1976d2);
    color: white;
    border-color: var(--menu-primary, #1976d2);
}

/* ========================================
   Modal Overlay (shared structure)
   ======================================== */
.item-modal-overlay,
.item-options-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.item-modal-overlay.active,
.item-options-overlay.active {
    display: flex;
}

.item-modal,
.item-options-modal {
    background: var(--menu-bg, white);
    border-radius: 12px;
    width: 90%;
    max-width: 550px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

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

.item-modal-header h3,
.item-options-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.item-modal-close,
.item-options-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--menu-text-muted, #666);
    padding: 0;
    line-height: 1;
}

.item-modal-body,
.item-options-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.item-modal-footer,
.item-options-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--menu-bg, white);
    flex-shrink: 0;
}

/* ========================================
   Responsive - 2 columns on mobile
   ======================================== */
@media (max-width: 600px) {
    .option-grid,
    .checkbox-list {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .option-item,
    .checkbox-option {
        padding: 10px 8px;
    }
    
    .option-name,
    .option-item-name {
        font-size: 13px;
    }
}

/* ========================================
   Mobile Modal - Top positioned for keyboard
   ======================================== */
@media (max-width: 768px) {
    /* Position modals at top of screen instead of center */
    .item-modal-overlay,
    .item-options-overlay {
        align-items: flex-start;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    /* Make modal scrollable and use dynamic viewport height */
    .item-modal,
    .item-options-modal {
        max-height: 85dvh;
        max-height: 85vh; /* fallback for older browsers */
        overflow-y: auto;
        margin: 0 10px;
    }
    
    /* Compact header */
    .item-modal-header,
    .item-options-header {
        padding: 12px 15px;
    }
    
    .item-modal-header h3,
    .item-options-title {
        font-size: 18px;
    }
    
    /* Compact body */
    .item-modal-body,
    .item-options-content {
        padding: 12px 15px;
    }
    
    /* Compact footer */
    .item-modal-footer,
    .item-options-footer {
        padding: 10px 15px;
    }
}
