/* ========================================
   RESTAURANT MENU APP - MODERN CSS
   Professional, Responsive, Animated
   ======================================== */

:root {
    /* Default colors - will be overridden by JS */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --secondary-dark: #7c3aed;
    --accent: #ec4899;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --dark: #1e293b;
    --darker: #0f172a;
    --light: #f8fafc;
    --gray: #64748b;
    --gray-light: #e2e8f0;
    --gray-dark: #334155;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--light) 0%, #f1f5f9 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-light);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal);
}

.animate-slide-in {
    animation: slideIn var(--transition-normal);
}

.animate-scale-in {
    animation: scaleIn var(--transition-normal);
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.page {
    animation: fadeIn var(--transition-normal);
}

/* Header & Navigation */
.navbar {
    background: white;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
}

.navbar-brand img {
    height: 40px;
    width: auto;
}

.navbar-menu {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.nav-link {
    color: var(--gray-dark);
    text-decoration: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-link:hover {
    background: var(--primary-light);
    color: white;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--gray-light);
    background: white;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--gray-light);
    background: var(--light);
}

/* Stats Cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: var(--spacing-sm) 0;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-dark);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-dark);
    transform: translateY(-2px);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: var(--warning-dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--dark);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-fast);
    background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input.error {
    border-color: var(--danger);
}

.form-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: var(--spacing-xs);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
}

.table th {
    background: var(--light);
    font-weight: 600;
    color: var(--gray-dark);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-preparing {
    background: #dbeafe;
    color: #1e40af;
}

.badge-ready {
    background: #d1fae5;
    color: #065f46;
}

.badge-completed {
    background: #d1fae5;
    color: #065f46;
}

.badge-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-lg);
}

.menu-item {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.menu-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.menu-item-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--gray-light);
}

.menu-item-content {
    padding: var(--spacing-md);
}

.menu-item-name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: var(--spacing-xs);
}

.menu-item-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.125rem;
}

.menu-item-category {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--gray-light);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    margin-top: var(--spacing-sm);
}

/* Order Cards */
.order-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    border-left: 4px solid var(--primary);
    transition: all var(--transition-normal);
}

.order-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.order-card.warning {
    border-left-color: var(--warning);
    background: linear-gradient(135deg, white, #fffbeb);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.order-number {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--primary);
}

.order-time {
    font-size: 0.75rem;
    color: var(--gray);
}

.order-items {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-md);
    background: var(--light);
    border-radius: var(--radius-md);
}

.order-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
    font-size: 0.875rem;
}

.order-total {
    font-weight: 700;
    font-size: 1.125rem;
    text-align: right;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--gray-light);
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    background: white;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.cart-sidebar.open {
    transform: translateX(0);
}

.cart-header {
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.cart-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--gray-light);
    background: var(--light);
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--gray-light);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
}

.cart-item-price {
    font-size: 0.875rem;
    color: var(--gray);
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 1100;
}

.toast {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-top: var(--spacing-sm);
    box-shadow: var(--shadow-lg);
    animation: slideInRight var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-width: 300px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-normal);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn var(--transition-normal);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--gray-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: var(--spacing-xs);
}

.lang-btn {
    background: none;
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.lang-btn.active {
    background: var(--primary);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }
    
    .navbar-container {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .navbar-brand {
        font-size: 1.125rem;
    }
    
    .menu-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--spacing-md);
    }
    
    .menu-item-image {
        height: 120px;
    }
    
    .cart-sidebar {
        width: 100%;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .table th,
    .table td {
        padding: var(--spacing-sm);
        font-size: 0.75rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .navbar-menu {
        gap: var(--spacing-xs);
    }
    
    .nav-link {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.75rem;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray); }

.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing-md); }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* Print Styles */
@media print {
    .navbar,
    .btn,
    .cart-sidebar,
    .modal {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ==========================================================================
   ACCOUNT DROPDOWN  (added 2026-10-26 by Ordis)
   --------------------------------------------------------------------------
   WHY THIS EXISTS
     .dropdown and .dropdown-menu had NO styles anywhere in this stylesheet,
     and no JavaScript toggled them. The account menu therefore rendered as a
     permanently OPEN, unstyled block of links.

     MEASURED on a real Android phone (OPPO PEMM00, Android 13): the menu ran
     off the right edge of the screen - "Admin Pane[l]" and "Kitche[n]" were
     cut off - and left a large empty gap under the header. A reviewer rated
     the mobile experience 3/10 purely because of this.

   THE FIX
     - hidden by default, shown by .open (toggled in base.html)
     - absolutely positioned and right-aligned so it can never overflow
     - on a phone it becomes a full-width panel pinned under the header,
       with taller touch targets
     - the brand text is hidden on small screens so the header stops crowding
   ========================================================================== */

.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 12px;
    box-shadow: 0 18px 44px -14px rgba(15, 23, 42, .38);
    padding: 6px;
    display: none;
    z-index: 1200;
    overflow: hidden;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 8px;
    color: #1e293b;
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
}

.dropdown-menu a:hover {
    background: #f1f5f9;
}

.dropdown-menu a i {
    width: 16px;
    text-align: center;
    opacity: .75;
}

.dropdown-menu hr {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 6px 4px;
}

@media (max-width: 768px) {
    /* A dropdown that is pinned to the header cannot overflow a phone. */
    .dropdown-menu {
        position: fixed;
        top: 62px;
        left: 12px;
        right: 12px;
        min-width: 0;
        max-width: none;
        border-radius: 14px;
    }

    .dropdown-menu a {
        padding: 14px;
        font-size: .95rem;
    }

    /* Keep the header on one line: icon only, no brand text. */
    .navbar-brand span {
        display: none;
    }

    .navbar-brand i,
    .navbar-brand img {
        height: 28px;
    }

    .navbar-container {
        gap: 8px;
    }

    .lang-switcher {
        gap: 2px;
    }

    .lang-btn {
        padding: 5px 7px;
        font-size: .7rem;
    }

    .dropdown-toggle {
        padding: 7px 10px;
        font-size: .8rem;
    }
}

/* ==========================================================================
   MOBILE SAFE AREA  (added 2026-10-26 by Ordis)
   --------------------------------------------------------------------------
   MEASURED on Rex's OPPO (Android 13): the third dashboard card, "Active
   Staff", was cut in half by the Android system navigation bar. The page had
   no bottom padding to account for it.

   env(safe-area-inset-bottom) is 0 on a device without a gesture bar and the
   real inset on one that has it, so this adds the right amount everywhere
   instead of guessing a fixed number.
   ========================================================================== */

@media (max-width: 768px) {
    main {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    /* Keep the toast above the navigation bar too. */
    .toast-container {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

/* The navbar is sticky; on a phone it must not overlap the status bar. */
.navbar {
    padding-top: env(safe-area-inset-top, 0px);
}
