/* ==================== REZEH - Unified Rider Portal Style ==================== */

/* CSS Variables */
:root {
    --ios-blue: #007AFF;
    --ios-red: #FF3B30;
    --ios-orange: #FF9500;
    --ios-green: #34C759;
    --ios-purple: #AF52DE;
    --ios-teal: #5AC8FA;

    --bg: #F2F2F7;
    --card: #FFFFFF;
    --text: #000000;
    --text-secondary: #8E8E93;
    --text-muted: #C7C7CC;
    --separator: #E5E5EA;
    --fill: #F2F2F7;
    --fill-secondary: #E5E5EA;
    --border: #E5E5EA;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    overflow-x: hidden;
}

/* ==================== LOGIN PAGE ==================== */
#login-container,
#login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.login-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: linear-gradient(135deg, #FF9500, #FF2D55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(255, 149, 0, 0.3);
}

.login-card h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 15px;
}

/* Login Overlay (for index.html) */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.login-overlay.show {
    display: flex;
}

.login-overlay .login-card {
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

/* ==================== NAVIGATION BAR ==================== */
.nav-bar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    max-width: 800px;
    margin: 0 auto;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Back Button */
.back-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--fill);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--ios-blue);
    transition: all 0.2s;
}

.back-btn:active {
    transform: scale(0.92);
    background: var(--fill-secondary);
}

.back-btn.hidden {
    visibility: hidden;
}

/* Avatar */
.avatar-ring {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF9500, #FF2D55);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

/* Connection Status */
.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ios-green);
    transition: background 0.3s;
}

.connection-dot.offline {
    background: var(--ios-red);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ==================== ALERT BANNER ==================== */
.alert-banner {
    background: var(--ios-blue);
    color: white;
    padding: 12px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.alert-banner:active {
    background: #0066d6;
}

.alert-badge {
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

/* ==================== HOME CARDS ==================== */
.cards-container {
    padding: 20px 16px;
    max-width: 600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.nav-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    border: none;
    font-family: inherit;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

.nav-card:active {
    transform: scale(0.96);
}

.nav-card .card-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.nav-card.dashboard .card-icon {
    background: #E8F2FF;
}

.nav-card.orders .card-icon {
    background: #FFF3E0;
}

.nav-card.earnings .card-icon {
    background: #E8F8ED;
}

.nav-card h3 {
    font-size: 15px;
    font-weight: 600;
}

.nav-card p {
    font-size: 12px;
    color: var(--text-secondary);
}

.card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--ios-red);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* ==================== SEGMENTED CONTROL ==================== */
.segmented-wrapper {
    padding: 8px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 52px;
    z-index: 99;
}

.segmented-scroll {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.segmented-scroll::-webkit-scrollbar {
    display: none;
}

.segment-item {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.segment-item:active {
    transform: scale(0.96);
}

.segment-item.active {
    background: var(--text);
    color: white;
    font-weight: 600;
}

.segment-badge {
    background: rgba(255,255,255,0.3);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.segment-item:not(.active) .segment-badge {
    background: var(--fill-secondary);
    color: var(--text-secondary);
}

.segment-badge.urgent {
    background: var(--ios-red);
    color: white;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ==================== STATS TILES ==================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px 16px;
    max-width: 800px;
    margin: 0 auto;
}

.stat-tile {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    border: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.stat-tile:active {
    transform: scale(0.96);
}

.stat-icon-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 18px;
}

.stat-tile h4 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.stat-tile p {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* ==================== CONTENT AREA ==================== */
.content {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.content-header h3 {
    font-size: 17px;
    font-weight: 600;
}

/* ==================== BUTTONS ==================== */
.btn-ios {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    min-height: 32px;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-ios:active {
    transform: scale(0.96);
}

.btn-ios:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Button Variants */
.btn-ios.primary {
    background: var(--ios-blue);
    color: white;
}

.btn-ios.success {
    background: var(--ios-green);
    color: white;
}

.btn-ios.warning {
    background: var(--ios-orange);
    color: white;
}

.btn-ios.danger {
    background: var(--ios-red);
    color: white;
}

.btn-ios.ghost {
    background: transparent;
    color: var(--ios-blue);
}

.btn-ios.gray {
    background: var(--fill);
    color: var(--text);
}

/* Button Sizes */
.btn-ios.small {
    padding: 4px 10px;
    font-size: 11px;
    min-height: 26px;
    border-radius: 14px;
}

.btn-ios.block {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: 15px;
    border-radius: 14px;
}

/* Special Buttons */
.btn-ios.btn-wa {
    background: #00a884;
    color: white;
}

.btn-ios.btn-call {
    background: #6366f1;
    color: white;
}

/* ==================== BADGES & PILLS ==================== */
.ios-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.ios-badge.blue {
    background: #E8F2FF;
    color: var(--ios-blue);
}

.ios-badge.orange {
    background: #FFF3E0;
    color: var(--ios-orange);
}

.ios-badge.green {
    background: #E8F8ED;
    color: var(--ios-green);
}

.ios-badge.purple {
    background: #F3E8FF;
    color: var(--ios-purple);
}

.ios-badge.red {
    background: #FFE5E5;
    color: var(--ios-red);
}

.ios-badge.gray {
    background: var(--fill);
    color: var(--text-secondary);
}

.ios-pill {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.ios-pill.paid {
    background: #E8F8ED;
    color: var(--ios-green);
}

.ios-pill.pending {
    background: #FFF3E0;
    color: var(--ios-orange);
}

.ios-pill.cod {
    background: #E8F2FF;
    color: var(--ios-blue);
}

/* ==================== ORDER CARDS ==================== */
.order-card-ios {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s;
}

.order-card-ios:active {
    transform: scale(0.98);
}

/* Card States */
.order-card-ios.all-ready {
    border-left: 4px solid var(--ios-green);
    background: #f0fdf4;
}

.order-card-ios.waiting {
    border-left: 4px solid var(--ios-orange);
    background: #fffbeb;
}

.order-card-ios.delivering {
    border-left: 4px solid var(--ios-blue);
    background: #eef2ff;
}

.order-card-ios.delivered {
    border-left: 4px solid var(--text-muted);
    opacity: 0.8;
}

/* Card Components */
.card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.order-id {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

/* Location Bar */
.location-bar {
    display: flex;
    justify-content: space-between;
    background: var(--fill);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 13px;
}

/* Brand Cards within Orders */
.brand-card {
    background: var(--fill);
    padding: 10px 12px;
    border-radius: 10px;
    margin: 6px 0;
    font-size: 13px;
    border-left: 3px solid transparent;
}

.brand-card.ready {
    background: #E8F8ED;
    border-left-color: var(--ios-green);
}

.brand-card.preparing {
    background: #FFF3E0;
    border-left-color: var(--ios-orange);
}

.brand-status-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 600;
    display: inline-block;
}

.brand-status-badge.ready {
    background: #d1fae5;
    color: var(--ios-green);
}

.brand-status-badge.preparing {
    background: #fef3c7;
    color: var(--ios-orange);
}

/* Summary Bar */
.summary-bar {
    padding: 10px 12px;
    border-radius: 10px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}

.summary-bar.all-ready {
    background: #E8F8ED;
    color: var(--ios-green);
}

.summary-bar.waiting {
    background: #FFF3E0;
    color: var(--ios-orange);
}

.summary-bar.delivering {
    background: #E8F2FF;
    color: var(--ios-blue);
}

/* Customer Info */
.customer-reveal {
    background: #E8F2FF;
    padding: 12px;
    border-radius: 10px;
    margin-top: 10px;
    font-size: 13px;
    border: 1px solid #c7d2fe;
}

.customer-locked {
    background: var(--fill);
    padding: 10px 12px;
    border-radius: 10px;
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px dashed var(--separator);
}

/* Action Bar */
.action-bar {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--fill-secondary);
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
}

/* ==================== LOADING ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(242, 242, 247, 0.9);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
}

.loading-overlay.show {
    display: flex;
}

.spinner-ios {
    width: 32px;
    height: 32px;
    border: 3px solid var(--fill-secondary);
    border-top-color: var(--ios-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 14px;
    color: white;
    z-index: 9999;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-width: 90vw;
    text-align: center;
}

.toast.success {
    background: rgba(52, 199, 89, 0.95);
}

.toast.error {
    background: rgba(255, 59, 48, 0.95);
}

.toast.info {
    background: rgba(0, 0, 0, 0.85);
}

.toast.warning {
    background: rgba(255, 149, 0, 0.95);
}

@keyframes toastIn {
    from {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
}

/* ==================== MODALS ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--fill);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-body {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* ==================== PWA INSTALL BUTTON ==================== */
#pwa-install-btn {
    display: none;
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--ios-blue);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    z-index: 9999;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
    border: none;
    font-family: inherit;
    white-space: nowrap;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.flex {
    display: flex !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-secondary);
}

.text-small {
    font-size: 12px;
}

.font-bold {
    font-weight: 700;
}

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ==================== SCROLLBAR STYLING ==================== */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--fill-secondary);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== SELECTION ==================== */
::selection {
    background: var(--ios-blue);
    color: white;
}

/* ==================== FOCUS STYLES ==================== */
:focus-visible {
    outline: 2px solid var(--ios-blue);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .location-bar {
        flex-direction: column;
        gap: 8px;
    }
    
    .action-bar {
        flex-direction: column;
    }
    
    .cards-container {
        grid-template-columns: 1fr;
    }
    
    .nav-card.earnings {
        grid-column: 1;
    }
}

@media (max-width: 400px) {
    .cards-container {
        gap: 10px;
        padding: 16px 12px;
    }
    
    .nav-card {
        padding: 20px 12px;
    }
    
    .login-card {
        padding: 24px 20px;
    }
    
    .segment-item {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ==================== DARK MODE SUPPORT (Optional) ==================== */
@media (prefers-color-scheme: dark) {
    /* Uncomment if you want dark mode support */
    /*
    :root {
        --bg: #000000;
        --card: #1C1C1E;
        --text: #FFFFFF;
        --text-secondary: #8E8E93;
        --text-muted: #48484A;
        --separator: #38383A;
        --fill: #2C2C2E;
        --fill-secondary: #3A3A3C;
        --border: #38383A;
    }
    */
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .nav-bar,
    .segmented-wrapper,
    .action-bar,
    .alert-banner,
    .loading-overlay,
    #pwa-install-btn {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .order-card-ios {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}