/* ============================================================
 *  Dishtro - Common CSS  v3 (Mobile width-safe edition)
 *  File: /app/assets/css/main.css
 * ============================================================
 *  Used by: index.php, login/, profile/, home/, pages/, etc.
 *  Loaded by: layout/header.php (auto)
 *
 *  KEY FIXES IN THIS VERSION:
 *  - 100svh / 100dvh fallbacks (fixes Safari iOS overflow)
 *  - max-width: 100% on everything (no horizontal overflow)
 *  - overflow-wrap: anywhere (long words/URLs don't break layout)
 *  - safe-area-inset support (notched phones)
 *  - min-width: 0 on flex children (text wraps properly)
 *  - No fixed widths anywhere — everything flexes down
 *  - Touch-friendly tap targets (44px min)
 *
 *  Load order in <head>:
 *    1. Google Fonts (Plus Jakarta Sans)
 *    2. Remix Icons
 *    3. THIS file
 *    4. Page-specific <style>
 * ============================================================ */


/* ============================================================
 *  1. CSS VARIABLES
 * ============================================================ */
:root {
    /* Brand */
    --d-primary:      #ff8d2f;
    --d-primary-dark: #f06b00;
    --d-veg:          #16a34a;
    --d-veg-dark:     #0f7a36;
    --d-danger:       #ef4444;

    /* Surfaces */
    --shell-bg:       #0a0a0a;
    --card-bg:        #15151a;
    --card-bd:        rgba(255,255,255,0.07);

    /* Text */
    --d-text:         #1a1a1a;
    --d-text-light:   #ffffff;
    --d-muted:        rgba(255, 255, 255, 0.78);
    --d-muted-2:      rgba(255, 255, 255, 0.45);

    /* Inputs */
    --input-bg:       rgba(255,255,255,0.07);
    --input-bd:       rgba(255,255,255,0.14);
    --input-bd-focus: var(--d-primary);

    /* Sizes */
    --frame-max-w:    480px;
    --frame-max-h:    880px;
    --nav-h:          78px;
    --save-bar-h:     90px;
    --pad-x:          22px;        /* unified horizontal padding */

    /* Dynamic viewport height (fallback chain) */
    --vh-100:         100vh;
}
@supports (height: 100dvh) {
    :root { --vh-100: 100dvh; }
}


/* ============================================================
 *  2. BASE RESET + GLOBAL WIDTH SAFETY
 *  Critical: every element clamps to its parent's width.
 * ============================================================ */
*,
*::before,
*::after {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    max-width: 100%;                       /* never exceed parent */
}

/* Long unbroken strings (emails, URLs, code) wrap instead of overflow */
body, p, span, h1, h2, h3, h4, h5, h6, li, a, label, div, td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Media elements never overflow their containers */
img, video, svg, picture, canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Form controls inherit width by default */
input, textarea, select, button {
    font-family: inherit;
    max-width: 100%;
}


/* ============================================================
 *  3. HTML / BODY
 *  Mobile: body scrolls natively. Horizontal overflow LOCKED.
 * ============================================================ */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100vw;
    background: var(--shell-bg);
    scrollbar-width: none;
    -ms-overflow-style: none;
}
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html {
    -webkit-text-size-adjust: 100%;        /* iOS: don't zoom text on rotate */
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;                     /* never horizontal scroll */
    overflow-y: auto;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--d-text-light);
    min-height: var(--vh-100);
    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    /* iOS Safari: bottom UI shouldn't overlap fixed elements */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}


/* ============================================================
 *  4. STAGE (phone frame container)
 *  On mobile, this fills the viewport so background extends to
 *  edges. .scroll-area inside flows naturally to its content.
 * ============================================================ */
.stage,
.dishtro-stage {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-height: var(--vh-100);
    background: var(--shell-bg);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}


/* ============================================================
 *  5. SCROLL AREA (mandatory wrapper)
 *  Mobile: flex child that grows to fill stage. Content sits
 *          naturally — no forced 100dvh, no false scroll.
 *  Desktop: position:absolute inside stage for internal scroll.
 * ============================================================ */
.scroll-area {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;                                   /* fill stage vertically */
    width: 100%;
    min-height: 0;                             /* allow flex shrink */
}


/* ============================================================
 *  6. DESKTOP PHONE FRAME  (>= 601px)
 * ============================================================ */
@media (min-width: 601px) {
    html, body {
        height: var(--vh-100);
        overflow: hidden;
    }
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px 0;
    }
    .stage,
    .dishtro-stage {
        position: relative !important;     /* CRITICAL: anchor for absolute .scroll-area */
        width: 100%;
        max-width: var(--frame-max-w);
        height: 100%;
        max-height: var(--frame-max-h);
        min-height: 0;
        border-radius: 32px;
        overflow: hidden !important;
        display: block !important;          /* override mobile flex */
        box-shadow:
            0 0 0 1px #000,
            0 25px 70px rgba(0, 0, 0, 0.75),
            0 8px 20px rgba(0, 0, 0, 0.5);
    }
    /* Force absolute internal scroll regardless of page-specific overrides */
    .scroll-area {
        position: absolute !important;
        inset: 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        /* keep flex column so flex children (like profile-setting save-bar) still work */
        display: flex;
        flex-direction: column;
    }
}


/* ============================================================
 *  7. BRAND MARK (logo + app name)
 * ============================================================ */
.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;                          /* lets text truncate if needed */
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.02em;
    color: #fff;
}
.brand-mark .logo-dot {
    flex-shrink: 0;                        /* logo never squishes */
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--d-primary), var(--d-primary-dark));
    display: grid;
    place-items: center;
    box-shadow: 0 10px 24px rgba(255, 141, 47, 0.4);
}
.brand-mark .logo-dot i { color: #fff; font-size: 20px; }
.brand-mark.brand-mark-sm { font-size: 18px; }
.brand-mark.brand-mark-sm .logo-dot {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(255, 141, 47, 0.35);
}
.brand-mark.brand-mark-sm .logo-dot i { font-size: 16px; }


/* ============================================================
 *  8. VEG BADGE
 * ============================================================ */
.veg-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}
.veg-symbol {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid var(--d-veg);
    border-radius: 3px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.95);
}
.veg-symbol::after {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--d-veg);
    border-radius: 50%;
}


/* ============================================================
 *  9. BACK BUTTON
 * ============================================================ */
.back-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 20px;
    text-decoration: none;
    backdrop-filter: blur(10px);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}
.back-btn:active { background: rgba(255, 255, 255, 0.16); }
.back-btn.back-btn-sm { width: 38px; height: 38px; font-size: 18px; }


/* ============================================================
 * 10. PRIMARY CTA BUTTON
 * ============================================================ */
.cta-btn {
    width: 100%;
    min-height: 52px;                      /* always tappable */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 17px 22px;
    background: linear-gradient(135deg, #ff8d2f 0%, #f06b00 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 16px;
    text-decoration: none;
    font-family: inherit;
    box-shadow:
        0 12px 28px rgba(255, 141, 47, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.cta-btn:active {
    transform: translateY(2px) scale(0.99);
    box-shadow: 0 6px 14px rgba(255, 141, 47, 0.35);
    color: #fff;
}
.cta-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.cta-btn .arrow {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: grid;
    place-items: center;
    font-size: 16px;
    transition: transform 0.2s ease;
}
.cta-btn:hover .arrow { transform: translateX(4px); }

.cta-btn-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    transform: skewX(-20deg);
    animation: dishtro-shimmer 2.6s ease-in-out infinite;
    pointer-events: none;
}
@keyframes dishtro-shimmer {
    0%, 60% { left: -120%; }
    100%    { left: 130%; }
}

.cta-btn .spinner {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dishtro-spin 0.7s linear infinite;
    display: none;
}
.cta-btn.loading .spinner { display: block; }
.cta-btn.loading .label-text,
.cta-btn.loading .arrow { display: none; }
@keyframes dishtro-spin { to { transform: rotate(360deg); } }


/* ============================================================
 * 11. FORM INPUTS
 * ============================================================ */
.field {
    margin-bottom: 18px;
    min-width: 0;                          /* flex children safety */
}
.field-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}
.field-label .req {
    color: var(--d-primary);
    font-size: 13px;
}
.field-label .verified {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 3px 8px;
    background: rgba(22, 163, 74, 0.15);
    border: 1px solid rgba(22, 163, 74, 0.35);
    border-radius: 999px;
    color: #4ade80;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: none;
    white-space: nowrap;
}
.field-label .verified i { font-size: 11px; }

.field-input {
    position: relative;
    min-width: 0;
}
.field-input .icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.45);
    font-size: 18px;
    pointer-events: none;
}

.input,
.textarea {
    width: 100%;
    padding: 15px 16px 15px 46px;
    background: var(--input-bg);
    border: 1px solid var(--input-bd);
    border-radius: 14px;
    font-family: inherit;
    font-size: 16px;                       /* 16px = iOS won't zoom on focus */
    font-weight: 500;
    color: #fff;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder,
.textarea::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}
.input:focus,
.textarea:focus {
    border-color: var(--input-bd-focus);
    background: rgba(255, 141, 47, 0.06);
}
.input:disabled,
.input[readonly] {
    cursor: not-allowed;
    color: rgba(255, 255, 255, 0.65);
}
.textarea {
    resize: none;
    min-height: 90px;
    padding-top: 14px;
    padding-bottom: 14px;
    line-height: 1.5;
}
.input.input-plain { padding-left: 16px; }

.field-help {
    margin: 6px 4px 0;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.45);
}
.field-error {
    display: none;
    margin: 6px 4px 0;
    font-size: 12px;
    color: #fca5a5;
    font-weight: 500;
}
.field.has-error .input,
.field.has-error .textarea {
    border-color: var(--d-danger);
    background: rgba(239, 68, 68, 0.06);
}
.field.has-error .field-error { display: block; }


/* ============================================================
 * 12. CHIPS (gender / address-label / filter pills)
 * ============================================================ */
.chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;                       /* wrap on narrow screens */
}
.chip {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--input-bg);
    border: 1px solid var(--input-bd);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}
.chip i { font-size: 16px; flex-shrink: 0; }
.chip:hover { background: rgba(255, 255, 255, 0.10); }
.chip.active {
    background: rgba(255, 141, 47, 0.12);
    border-color: var(--d-primary);
    color: #fff;
}


/* ============================================================
 * 13. ALERT
 * ============================================================ */
.alert {
    display: none;
    padding: 12px 14px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.30);
    border-radius: 12px;
    color: #fecaca;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    align-items: flex-start;
    gap: 8px;
}
.alert.show { display: flex; }
.alert.success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.30);
    color: #bbf7d0;
}
.alert i {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}


/* ============================================================
 * 14. TOAST
 * ============================================================ */
.toast {
    position: fixed;
    top: max(80px, env(safe-area-inset-top, 0px) + 60px);
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999;
    padding: 12px 18px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    max-width: calc(100vw - 32px);
    width: max-content;
}
.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: rgba(34, 197, 94, 0.5); color: #bbf7d0; }
.toast.error   { border-color: rgba(239, 68, 68, 0.5); color: #fecaca; }
.toast i { font-size: 18px; flex-shrink: 0; }


/* ============================================================
 * 15. STICKY SAVE BAR
 * ============================================================ */
.save-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding:
        14px
        max(var(--pad-x), env(safe-area-inset-right))
        max(14px, env(safe-area-inset-bottom))
        max(var(--pad-x), env(safe-area-inset-left));
    background: linear-gradient(180deg,
        rgba(10, 10, 10, 0) 0%,
        rgba(10, 10, 10, 0.92) 30%,
        #0a0a0a 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
@media (min-width: 601px) {
    .save-bar {
        position: absolute;
        border-bottom-left-radius: 32px;
        border-bottom-right-radius: 32px;
    }
}


/* ============================================================
 * 16. STICKY TOP BAR
 * ============================================================ */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding:
        max(16px, env(safe-area-inset-top))
        18px
        14px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    width: 100%;
}
.top-bar .top-title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ============================================================
 * 17. ENTRANCE ANIMATIONS
 * ============================================================ */
.anim-up {
    opacity: 0;
    transform: translateY(20px);
    animation: dishtro-rise 0.7s ease forwards;
}
.anim-up.d1 { animation-delay: 0.10s; }
.anim-up.d2 { animation-delay: 0.22s; }
.anim-up.d3 { animation-delay: 0.34s; }
.anim-up.d4 { animation-delay: 0.46s; }
.anim-up.d5 { animation-delay: 0.58s; }
@keyframes dishtro-rise {
    to { opacity: 1; transform: translateY(0); }
}

/* Respect user's reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    .anim-up,
    .cta-btn-shimmer::after,
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ============================================================
 * 18. SKELETON LOADERS (shimmer placeholders)
 *  Usage:
 *   - <div class="skel skel-line"></div>   ← single shimmer line
 *   - Wrap real content in .content-block
 *   - Wrap skeleton placeholders in .skeleton-block
 *   - JS adds body.loaded → skeletons hide, content shows
 * ============================================================ */
.skel {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.04) 0%,
        rgba(255,255,255,0.10) 50%,
        rgba(255,255,255,0.04) 100%
    );
    background-size: 200% 100%;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: 10px;
}
@keyframes skel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Common skeleton shapes */
.skel-line     { height: 12px; border-radius: 6px; }
.skel-line.sm  { height: 10px; }
.skel-line.lg  { height: 16px; }
.skel-line.w30 { width: 30%; }
.skel-line.w40 { width: 40%; }
.skel-line.w50 { width: 50%; }
.skel-line.w60 { width: 60%; }
.skel-line.w70 { width: 70%; }
.skel-line.w80 { width: 80%; }
.skel-line.w90 { width: 90%; }
.skel-circle   { border-radius: 50%; }
.skel-rounded  { border-radius: 16px; }

/* ===== TOGGLE LOGIC =====
 * Default state (page just loaded, before body.loaded class):
 *   - skeleton-block SHOWS
 *   - content-block HIDES
 * After body.loaded (added by footer reveal script):
 *   - skeleton-block HIDES
 *   - content-block SHOWS
 *
 * Using !important + display: none ensures no page-specific
 * style can accidentally override these.
 */
.skeleton-block { display: block !important; }
.content-block  { display: none  !important; }

body.loaded .skeleton-block { display: none  !important; }
body.loaded .content-block  { display: block !important; }

/* If JS is disabled, skeletons would loop forever — show content instead */
.no-js .skeleton-block { display: none !important; }
.no-js .content-block  { display: block !important; }


/* ============================================================
 * 19. UTILITY HELPERS
 * ============================================================ */
.text-grad-orange {
    background: linear-gradient(90deg, #fbbf24 0%, #ff8d2f 50%, #ff5e3a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.text-muted   { color: var(--d-muted); }
.text-muted-2 { color: var(--d-muted-2); }
.flex-grow    { flex: 1; min-width: 0; }
.no-scrollbar {
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}
.no-scrollbar::-webkit-scrollbar { display: none; width: 0; height: 0; }
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ============================================================
 * 19. RESPONSIVE TWEAKS
 * ============================================================ */

/* Tiny phones (iPhone SE / older Androids) */
@media (max-width: 360px) {
    :root {
        --pad-x: 16px;                     /* less padding on tiny screens */
    }
    .cta-btn { font-size: 15px; padding: 15px 18px; }
    .top-bar { padding-left: 14px; padding-right: 14px; }
}

/* Short screens (landscape phones, small Android) */
@media (max-height: 640px) {
    .cta-btn { padding: 15px 20px; font-size: 15px; }
}

/* Prevent iOS rubber-banding past document on touch devices */
@media (hover: none) {
    body { overscroll-behavior: none; }
}

