/**
 * Serendipity POS - Common Styles
 * Defensive IT: Zero external dependencies
 * Restaurant Theme - Navy & Gold
 */

/* ===== CSS RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== CSS VARIABLES ===== */
:root {
    /* Primary Colors - Navy & Gold Restaurant Theme */
    --primary: #1a3a52;
    --primary-light: #2d5f7f;
    --accent: #d4af37;
    --accent-hover: #b8971f;
    
    /* Status Colors */
    --success: #2d7a4f;
    --success-hover: #246339;
    --danger: #c73e3a;
    --danger-hover: #a73430;
    --secondary: #64748b;
    --secondary-hover: #475569;
    
    /* Backgrounds - Warm Tones */
    --bg: #f8f6f2;
    --card: #ffffff;
    
    /* Text Colors */
    --text: #2c2c2c;
    --text-light: #666;
    --text-muted: #94a3b8;
    
    /* Borders - Warm Neutral */
    --border: #e5e1d8;
    --border-dark: #cbd5e1;
    
    /* Shadows */
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

/* ===== BASE STYLES ===== */
body {
    font-family: 'Work Sans', sans-serif;
    background: linear-gradient(135deg, #f8f6f2 0%, #e8e4dc 100%);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ===== MASTER HEADER - All sub-pages ===== */
header {
    background: var(--card);
    padding: 2rem 3rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border-left: 6px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-family: 'Work Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    text-transform: capitalize;
}

/* ===== HAMBURGER MENU ===== */
.hamburger-toggle {
    position: static;
    z-index: 100;
    width: 3rem;
    height: 3rem;
    background: var(--accent);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.hamburger-toggle:hover {
    background: white;
    border-color: var(--accent);
    transform: scale(1.05);
}

.hamburger-line {
    width: 1.5rem;
    height: 2px;
    max-height: 2px;
    background: var(--primary);
    border-radius: 1px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.hamburger-toggle:hover .hamburger-line {
    background: var(--accent);
}

/* Hamburger Navigation */
.hamburger-nav {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    transition: left 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.hamburger-nav.active {
    left: 0;
}

.nav-header {
    padding: 2rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-header h3 {
    font-family: 'Work Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.nav-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-close:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex: 1;
}

.nav-menu li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 1rem 2rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--primary);
    border-left-color: var(--accent);
}

.nav-link.active {
    background: var(--bg);
    color: var(--primary);
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-footer {
    padding: 2rem;
    border-top: 2px solid var(--border);
}

.btn-logout {
    width: 100%;
    padding: 0.875rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Work Sans', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: var(--danger-hover);
    transform: translateY(-2px);
}

/* Hamburger Overlay */
.hamburger-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.hamburger-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-family: 'Work Sans', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--accent);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
}

.btn-secondary {
    background: var(--card);
    color: var(--primary);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-back {
    padding: 0.75rem 1.5rem;
    background: var(--card);
    color: var(--primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
}

.btn-back:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.header-buttons {
    display: flex;
    gap: 1rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'Work Sans', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Custom form row for Name/Website + Address layout */
.form-row-custom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-col-left {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-col-left .form-group {
    margin-bottom: 0;
}

.form-col-right .form-group {
    margin-bottom: 0;
}

.form-col-right textarea {
    height: 100%;
    min-height: 150px;
    resize: vertical;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

select.form-control {
    cursor: pointer;
    background: white;
}

/* Time range inputs */
.time-range-inputs {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.time-input {
    max-width: 150px;
}

.time-separator {
    color: var(--text-light);
    font-weight: 500;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-active,
.open-badge {
    background: #d4f4dd;
    color: var(--success);
}

.badge-inactive,
.closed-badge {
    background: #ffe0df;
    color: var(--danger);
}

/* ===== MESSAGES ===== */
.error {
    background: #ffe0df;
    color: var(--danger);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--danger);
}

.success {
    background: #d4f4dd;
    color: var(--success);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--success);
}

/* ===== LOADING STATES ===== */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    font-size: 1.1rem;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    margin-left: 1rem;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* ===== FORM ACTIONS ===== */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
}

.btn-group-left,
.btn-group-right {
    display: flex;
    gap: 1rem;
}

/* ===== TABLES ===== */
.table-container {
    background: var(--card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    background: var(--primary);
    border-radius: 12px 12px 0 0;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

th:first-child {
    border-top-left-radius: 12px;
}

th:last-child {
    border-top-right-radius: 12px;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg);
}

.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
}

.btn-icon:hover {
    transform: translateY(-2px);
}

.btn-edit {
    color: var(--primary);
    background: #dbeafe;
}

.btn-edit:hover {
    background: #bfdbfe;
}

.btn-delete {
    color: var(--danger);
    background: #fee2e2;
}

.btn-delete:hover {
    background: #fecaca;
}

/* ===== TABLE ACTIONS CELL ===== */
.actions-cell {
    text-align: right;
    white-space: nowrap;
    width: 200px;
}

.actions-cell button {
    margin-left: 0.5rem;
    min-width: 70px;
}

.actions-cell button:first-child {
    margin-left: 0;
}

/* ===== TABLE SCROLLBAR (Webkit browsers) ===== */
.menu-types-table::-webkit-scrollbar,
.menu-categories-table::-webkit-scrollbar,
.hours-table::-webkit-scrollbar {
    height: 8px;
}

.menu-types-table::-webkit-scrollbar-track,
.menu-categories-table::-webkit-scrollbar-track,
.hours-table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.menu-types-table::-webkit-scrollbar-thumb,
.menu-categories-table::-webkit-scrollbar-thumb,
.hours-table::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.menu-types-table::-webkit-scrollbar-thumb:hover,
.menu-categories-table::-webkit-scrollbar-thumb:hover,
.hours-table::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ===== RESPONSIVE ===== */
/* Tablet Portrait - Stack header and form-action buttons */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    h1 {
        font-size: 1.75rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-row-custom {
        grid-template-columns: 1fr;
    }
    
    .form-col-left {
        gap: 1.5rem;
    }
    
    /* Stack header buttons */
    .header-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .header-buttons .btn-back {
        width: 100%;
    }
    
    /* Stack form-action buttons */
    .form-actions {
        flex-direction: column;
    }

    .btn-group-left,
    .btn-group-right {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
    
    /* Make grid action buttons smaller on tablet portrait */
    .actions-cell {
        width: 170px;
        min-width: 170px;
    }
    
    .actions-cell button {
        min-width: 65px;
        max-width: 78px;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        margin-left: 0.4rem;
    }
    
    /* Override btn-small in action cells */
    .actions-cell .btn-small {
        min-width: 65px;
        max-width: 78px;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .actions-cell button:first-child {
        margin-left: 0;
    }
}

/* Smaller Tablet Portrait - Tighter spacing for smaller tablets */
@media (max-width: 600px) {
    /* Make grid action buttons even smaller */
    .actions-cell {
        width: 155px;
        min-width: 155px;
    }
    
    .actions-cell button {
        min-width: 60px;
        max-width: 72px;
        padding: 0.38rem 0.5rem;
        font-size: 0.75rem;
        margin-left: 0.3rem;
    }
    
    /* Override btn-small in action cells */
    .actions-cell .btn-small {
        min-width: 60px;
        max-width: 72px;
        padding: 0.38rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .actions-cell button:first-child {
        margin-left: 0;
    }
}

/* Mobile - Stack bottom buttons */
@media (max-width: 480px) {
    .form-actions {
        flex-direction: column;
    }

    .btn-group-left,
    .btn-group-right {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
    
    /* Smaller action buttons for mobile */
    .actions-cell {
        width: 140px;
        min-width: 140px;
    }
    
    .actions-cell button {
        min-width: 55px;
        max-width: 65px;
        padding: 0.35rem 0.4rem;
        font-size: 0.7rem;
        margin-left: 0.25rem;
    }
    
    /* Override btn-small in action cells */
    .actions-cell .btn-small {
        min-width: 55px;
        max-width: 65px;
        padding: 0.35rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .actions-cell button:first-child {
        margin-left: 0;
    }
}

/* Extra Small Mobile - Very tight spacing for small phones */
@media (max-width: 400px) {
    .actions-cell {
        width: 120px;
        min-width: 120px;
    }
    
    .actions-cell button {
        min-width: 48px;
        max-width: 56px;
        padding: 0.3rem 0.25rem;
        font-size: 0.65rem;
        margin-left: 0.15rem;
    }
    
    /* Override btn-small in action cells */
    .actions-cell .btn-small {
        min-width: 48px;
        max-width: 56px;
        padding: 0.3rem 0.25rem;
        font-size: 0.65rem;
    }
    
    .actions-cell button:first-child {
        margin-left: 0;
    }
}