:root {
    --font-body: 'Poppins', sans-serif;
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --bg-color: #f4f6f8;
    --surface-color: #ffffff;
    --text-primary: #121828;
    --text-secondary: #637381;
    --border-color: #e5e8eb;
    --primary: #5a4bda; /* Modern rich purple/blue instead of coral */
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --accent-green: #10b981;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 12px 30px rgba(90, 75, 218, 0.12);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius-sm: 8px;
    --status-pending-bg: #fffbeb; --status-pending-fg: #d97706;
    --status-accepted-bg: #e0e7ff; --status-accepted-fg: #4338ca;
    --status-preparing-bg: #dbeafe; --status-preparing-fg: #2563eb;
    --status-ready-bg: #ecfdf5; --status-ready-fg: #059669;
    --status-progress-bg: #f3f4f6; --status-progress-fg: #374151;
    --status-out-bg: #fef3c7; --status-out-fg: #d97706;
    --status-completed-bg: #ecfdf5; --status-completed-fg: #10b981;
    --status-error-bg: #fee2e2; --status-error-fg: #dc2626;
}

body.dark {
    --bg-color: #0f0f1a;
    --surface-color: #1a1a2e;
    --text-primary: #f0f0f5;
    --text-secondary: #8b8ba3;
    --border-color: rgba(255, 255, 255, 0.08);
    --primary: #6c5ce7;
    --primary-dark: #5a4bda;
    --primary-light: rgba(108, 92, 231, 0.15);
    --primary-glow: rgba(108, 92, 231, 0.4);
    --success: #00cec9;
    --warning: #fdcb6e;
    --danger: #ff7675;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 12px 30px rgba(108, 92, 231, 0.2);
    --status-pending-bg: rgba(217, 119, 6, 0.15); --status-pending-fg: #fbbf24;
    --status-accepted-bg: rgba(67, 56, 202, 0.15); --status-accepted-fg: #818cf8;
    --status-preparing-bg: rgba(37, 99, 235, 0.15); --status-preparing-fg: #60a5fa;
    --status-ready-bg: rgba(5, 150, 105, 0.15); --status-ready-fg: #34d399;
    --status-progress-bg: rgba(55, 65, 81, 0.5); --status-progress-fg: #9ca3af;
    --status-out-bg: rgba(217, 119, 6, 0.15); --status-out-fg: #fbbf24;
    --status-completed-bg: rgba(16, 185, 129, 0.15); --status-completed-fg: #34d399;
    --status-error-bg: rgba(220, 38, 38, 0.15); --status-error-fg: #f87171;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    background-image: 
        radial-gradient(circle at top left, rgba(90, 75, 218, 0.04) 0%, transparent 40%),
        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark {
    background-image:
        radial-gradient(circle at top left, rgba(108, 92, 231, 0.08) 0%, transparent 40%),
        radial-gradient(circle at bottom right, rgba(0, 206, 201, 0.06) 0%, transparent 40%);
}

/* Tab Navigation */
.orders-tabs {
    display: flex;
    gap: 8px;
    max-width: 900px;
    margin: 0 auto 24px;
    padding: 0 20px;
}

.tab-btn {
    flex: 1;
    padding: 14px 20px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tab-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(90, 75, 218, 0.3);
}

.tab-btn.active i {
    color: #fff;
}

.tab-badge {
    background: #fff;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============ COMPACT PREMIUM HEADER ============ */
.orders-header {
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 24px;
    padding: 16px 4px 0; /* Reduced to let the capsule stretch closer to screen edges */
    transition: all 0.3s ease;
    pointer-events: none; /* Let clicks pass through margins */
}

/* Nav bar row */
.header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 28px; /* Extended left and right padding for the capsule effect */
    pointer-events: auto; /* Re-enable clicks inside the capsule */
    
    /* Capsule Styling */
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

body.dark .header-nav {
    background: rgba(26, 26, 46, 0.95);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-title {
    font-size: 1.4rem;
    font-family: var(--font-heading);
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

/* Icon buttons (back + theme toggle) */
.nav-back,
.nav-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    flex-shrink: 0;
}

body.dark .nav-back,
body.dark .nav-icon-btn,
body.dark .user-chip {
    background: rgba(255, 255, 255, 0.06);
}

.nav-back:hover,
.nav-icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(90, 75, 218, 0.18);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* User chip */
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-color);
    border: none;
    border-radius: 999px;
    padding: 6px 16px 6px 6px;
    transition: all 0.3s ease;
    max-width: 200px;
}

.user-chip:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 16px rgba(90, 75, 218, 0.08);
}

.user-chip-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.user-chip span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .header-nav { padding: 12px 20px; }
    .nav-left { gap: 12px; }
    .nav-title { font-size: 1.25rem; }
    .user-chip { max-width: 130px; padding: 4px 12px 4px 4px; }
    .user-chip-avatar { width: 28px; height: 28px; font-size: 0.65rem; }
    .user-chip span { font-size: 0.8rem; }
    .nav-back, .nav-icon-btn { width: 36px; height: 36px; border-radius: 50%; font-size: 0.85rem; }
}

/* Main Content Area */
.orders-main {
    padding: 10px 0 80px;
    min-height: calc(100vh - 150px);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

.empty-state i {
    font-size: 4.5rem;
    color: #e2e8f0;
    margin-bottom: 24px;
    background: #f8fafc;
    width: 120px;
    height: 120px;
    line-height: 120px;
    border-radius: 50%;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}

.empty-state h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.05rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--text-primary);
    color: white;
    padding: 14px 32px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 1.05rem;
    box-shadow: 0 4px 15px rgba(18, 24, 40, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: var(--primary);
    box-shadow: 0 8px 25px rgba(90, 75, 218, 0.3);
}

/* Orders List */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.order-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.order-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
    border-color: rgba(90, 75, 218, 0.2);
}

.order-header-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 20px;
}

.order-title {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-id {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-id::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.order-date {
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.order-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.order-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: #f1f5f9;
    color: #475569;
}

.order-status.pending { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.order-status.accepted { background: var(--status-accepted-bg); color: var(--status-accepted-fg); }
.order-status.preparing { background: var(--status-preparing-bg); color: var(--status-preparing-fg); }
.order-status.ready_for_pickup { background: var(--status-ready-bg); color: var(--status-ready-fg); }
.order-status.in_progress { background: var(--status-progress-bg); color: var(--status-progress-fg); }
.order-status.out_for_delivery { background: var(--status-out-bg); color: var(--status-out-fg); }
.order-status.completed { background: var(--status-completed-bg); color: var(--status-completed-fg); }
.order-status.delivered { background: var(--status-completed-bg); color: var(--status-completed-fg); }
.order-status.rejected { background: var(--status-error-bg); color: var(--status-error-fg); }
.order-status.cancelled { background: var(--status-error-bg); color: var(--status-error-fg); }

.order-total {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.order-body {
    padding: 0;
}

.order-shop {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 8px 16px;
    background: var(--bg-color);
    border-radius: 999px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.order-shop i {
    color: var(--primary);
}

.order-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease;
}

.order-item:hover {
    border-color: rgba(90, 75, 218, 0.3);
}

.item-name {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.item-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-heading);
}

.item-variant {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
    width: fit-content;
    font-weight: 500;
}

.item-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.item-quantity {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.order-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    margin-top: 24px;
    border: 1px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.summary-row.subtotal {
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-row.total {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px dashed #cbd5e1;
}

.order-actions {
    display: flex;
    gap: 16px;
    padding-top: 24px;
    margin-top: 8px;
}

.btn-secondary {
    flex: 1;
    padding: 14px 20px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn-secondary i {
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: color 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(90, 75, 218, 0.1);
}

.btn-secondary:hover i {
    color: var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 40px;
}

.modal-order-header {
    margin-bottom: 32px;
}

.modal-order-id {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

.modal-order-status {
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.modal-shop-info {
    margin-bottom: 20px;
    padding: 12px;
    background: var(--status-pending-bg);
    border-radius: 8px;
    border-left: 4px solid var(--status-pending-fg);
}

.modal-shop-info p {
    margin: 0;
}

.modal-customer-info {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
}

.modal-status-info {
    margin-top: 20px;
    padding: 12px;
    background: var(--status-preparing-bg);
    border-radius: 8px;
    border-left: 4px solid var(--status-preparing-fg);
}

body.dark .modal-content {
    background: var(--surface-color);
}

/* Responsive */
@media (max-width: 768px) {
    .order-card { padding: 20px; }
    
    .order-header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .order-meta {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .order-actions {
        flex-direction: column;
    }

    .modal-body { padding: 24px; }
}
