/* ============================================================
   MIRANDA'S LIST THEME — ml-theme.css
   CSS custom properties, background textures, animations,
   and shared utility classes.
   ============================================================ */

/* ── Auth Visibility (separate from Tailwind's hidden to avoid conflicts) ── */
.auth-hidden { display: none !important; }

/* ── Color Palette ── */
:root {
    --bg:             #FAFAF8;
    --bg-alt:         #F5F3EF;
    --surface:        #FFFFFF;
    --surface-light:  #F8F6F2;
    --text-main:      #2D3436;
    --text-muted:     #636E72;
    --primary:        #5B8A72;
    --primary-hover:  #4A7360;
    --primary-dim:    rgba(91, 138, 114, 0.10);
    --accent:         #E07A5F;
    --accent-hover:   #C96B52;
    --accent-dim:     rgba(224, 122, 95, 0.10);
    --border:         rgba(0, 0, 0, 0.08);
    --border-subtle:  rgba(0, 0, 0, 0.05);
    --input-bg:       rgba(0, 0, 0, 0.03);
    --input-border:   rgba(0, 0, 0, 0.12);
    --input-bg-focus: rgba(0, 0, 0, 0.05);
    --card-shadow:    0 2px 12px -2px rgba(0, 0, 0, 0.06), 0 4px 16px -4px rgba(0, 0, 0, 0.04);
    --card-shadow-lg: 0 4px 20px -4px rgba(0, 0, 0, 0.08), 0 8px 32px -8px rgba(0, 0, 0, 0.06);

    /* Status colors */
    --success-bg:     rgba(91, 138, 114, 0.10);
    --success-border: rgba(91, 138, 114, 0.25);
    --success-text:   #4A7360;
    --error-bg:       rgba(220, 38, 38, 0.08);
    --error-border:   rgba(220, 38, 38, 0.25);
    --error-text:     #DC2626;
    --warning-bg:     rgba(245, 158, 11, 0.08);
    --warning-border: rgba(245, 158, 11, 0.25);
    --warning-text:   #B45309;
}

/* ── Body Base ── */
body {
    background-color: var(--bg);
    color: var(--text-main);
    -webkit-tap-highlight-color: transparent;
}

/* ── Organic Background Texture ──
     Gentle, flowing contour lines inspired by natural
     topography — warm and food-friendly.              */
.bg-texture {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='600'%3E%3Cpath d='M0,50 Q100,30 200,50 T400,50 T600,50 T800,50' fill='none' stroke='rgba(91,138,114,0.04)' stroke-width='1'/%3E%3Cpath d='M0,100 Q100,75 200,100 T400,100 T600,100 T800,100' fill='none' stroke='rgba(224,122,95,0.03)' stroke-width='1'/%3E%3Cpath d='M0,155 Q120,130 200,155 T400,155 T600,155 T800,155' fill='none' stroke='rgba(91,138,114,0.035)' stroke-width='1'/%3E%3Cpath d='M0,200 Q90,172 200,200 T400,200 T600,200 T800,200' fill='none' stroke='rgba(224,122,95,0.025)' stroke-width='1'/%3E%3Cpath d='M0,250 Q110,225 200,250 T400,250 T600,250 T800,250' fill='none' stroke='rgba(91,138,114,0.03)' stroke-width='1'/%3E%3Cpath d='M0,295 Q80,268 200,295 T400,295 T600,295 T800,295' fill='none' stroke='rgba(224,122,95,0.03)' stroke-width='1'/%3E%3Cpath d='M0,340 Q130,315 200,340 T400,340 T600,340 T800,340' fill='none' stroke='rgba(91,138,114,0.025)' stroke-width='1'/%3E%3Cpath d='M0,390 Q100,362 200,390 T400,390 T600,390 T800,390' fill='none' stroke='rgba(224,122,95,0.035)' stroke-width='1'/%3E%3Cpath d='M0,440 Q120,418 200,440 T400,440 T600,440 T800,440' fill='none' stroke='rgba(91,138,114,0.03)' stroke-width='1'/%3E%3Cpath d='M0,490 Q90,465 200,490 T400,490 T600,490 T800,490' fill='none' stroke='rgba(224,122,95,0.025)' stroke-width='1'/%3E%3Cpath d='M0,540 Q110,518 200,540 T400,540 T600,540 T800,540' fill='none' stroke='rgba(91,138,114,0.03)' stroke-width='1'/%3E%3Cpath d='M0,580 Q80,562 200,580 T400,580 T600,580 T800,580' fill='none' stroke='rgba(224,122,95,0.02)' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 800px 600px;
}

/* ── Navbar ── */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    background: rgba(250, 250, 248, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

/* ── Nav Pill Buttons ── */
.nav-pill {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1rem; border-radius: 0.75rem;
    font-weight: 600; font-size: 0.875rem;
    color: var(--text-muted); background: transparent;
    border: none; cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
    text-decoration: none;
}
.nav-pill:hover { color: var(--primary); background-color: var(--primary-dim); }
.nav-pill.active { color: var(--primary); background-color: var(--primary-dim); }

/* ── Hero Gradient Orbs ── */
.hero-orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(100px);
}
.hero-orb-green {
    width: 500px; height: 500px;
    top: -15%; left: -5%;
    background: rgba(91, 138, 114, 0.08);
    animation: orbFloat 20s ease-in-out infinite alternate;
}
.hero-orb-terra {
    width: 400px; height: 400px;
    top: 0%; right: -8%;
    background: rgba(224, 122, 95, 0.06);
    animation: orbFloat 25s ease-in-out infinite alternate-reverse;
}
.hero-orb-small {
    width: 250px; height: 250px;
    bottom: 5%; left: 35%;
    background: rgba(91, 138, 114, 0.05);
    animation: orbFloat 18s ease-in-out infinite alternate;
}
@keyframes orbFloat {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(30px, -20px) scale(1.05); }
    100% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ── Card Effects ── */
.recipe-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--card-shadow);
}
.recipe-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-lg);
}

/* ── Squish Button Animation ── */
.squish {
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.squish:active {
    transform: scale(0.95);
}

/* ── Filter Chip Active State ── */
.filter-chip {
    transition: all 0.2s ease;
}
.filter-chip.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Gradient Text ── */
.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Mobile Nav Panel ── */
.mobile-nav-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 280px;
    z-index: 60;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-nav-panel.open {
    transform: translateX(0);
}
.mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.mobile-nav-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Toast Notifications ── */
.toast {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 2rem);
}
@media (min-width: 768px) { .toast { bottom: 2rem; } }
.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Scroll offset for fixed navbar ── */
html {
    scroll-padding-top: 80px;
}

/* ── Smooth scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.20);
}

/* ── Section alternating backgrounds ── */
.section-alt {
    background-color: var(--bg-alt);
}

/* ── Image zoom on hover ── */
.img-zoom {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.group:hover .img-zoom {
    transform: scale(1.05);
}

/* ── Badge pill ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ── Modal Overlay ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
    }
}

/* ── Modal Sheet ── */
.modal-sheet {
    background: var(--surface);
    border-radius: 1.5rem 1.5rem 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
.modal-overlay.active .modal-sheet {
    transform: translateY(0);
}
@media (min-width: 768px) {
    .modal-sheet {
        border-radius: 1.5rem;
        transform: translateY(20px) scale(0.95);
    }
    .modal-overlay.active .modal-sheet {
        transform: translateY(0) scale(1);
    }
}
/* Medium modal — recipe detail view (wider on desktop, same on mobile) */
.modal-sheet-md {
    max-width: 480px;
}
@media (min-width: 768px) {
    .modal-sheet-md {
        max-width: 800px;
    }
}

/* Fullscreen modal — recipe detail expanded view (great for tablets) */
.modal-sheet.modal-fullscreen {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
}
.modal-sheet.modal-fullscreen .modal-fullscreen-content {
    max-height: calc(100vh - 70px);
}

/* Large modal — recipe form (wider on desktop, same on mobile) */
.modal-sheet-lg {
    max-width: 800px;
}
@media (min-width: 768px) {
    .modal-sheet-lg {
        max-width: 900px;
    }
}

/* ── Skeleton Shimmer ── */
.skeleton-shimmer {
    background: linear-gradient(90deg, var(--bg-alt) 25%, var(--surface-light) 50%, var(--bg-alt) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ── Grocery Panel — Slide-out from right ── */
.grocery-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 420px;
    z-index: 70;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.08);
}
.grocery-panel.open {
    transform: translateX(0);
}
.grocery-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.grocery-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Pantry Panel — Slide-out from right ── */
.pantry-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 420px;
    z-index: 70;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.08);
}
.pantry-panel.open {
    transform: translateX(0);
}
.pantry-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.pantry-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Village Panel — Slide-out from right ── */
.village-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 420px;
    z-index: 70;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.08);
}
.village-panel.open { transform: translateX(0); }
.village-backdrop {
    position: fixed; inset: 0; z-index: 65;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.village-backdrop.open { opacity: 1; pointer-events: auto; }

/* Pantry location filter tabs */
.pantry-location-tab {
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}
.pantry-location-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pantry-location-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Scanner viewfinder */
#pantry-scanner-region video {
    border-radius: 1rem;
}
#pantry-scanner-region {
    border-radius: 1rem;
    overflow: hidden;
}

/* ── Ingredient Autocomplete Dropdown ── */
.ingredient-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 80;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow-lg);
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
/* Taller when showing the quick-add form so controls aren't cramped */
.ingredient-autocomplete:has(.quick-add-form) {
    max-height: 320px;
}
.ingredient-autocomplete.visible {
    opacity: 1;
    pointer-events: auto;
}
.autocomplete-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.1s ease;
}
.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background-color: var(--bg-alt);
}
.autocomplete-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
}
.autocomplete-category {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.autocomplete-empty {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.autocomplete-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* ── Quick-Add Ingredient Form ── */
.quick-add-form {
    padding: 1rem;
}
.quick-add-header {
    font-size: 0.875rem;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.quick-add-row {
    display: flex;
    gap: 0.5rem;
}
.quick-add-category {
    flex: 1;
    padding: 0.5rem 0.625rem;
    border-radius: 0.625rem;
    border: 1px solid var(--input-border);
    background: var(--surface);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}
.quick-add-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.625rem;
    background: var(--primary);
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}
.quick-add-btn:hover {
    opacity: 0.85;
}
.quick-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Step Drag-and-Drop ── */
.step-row {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    /* Prevent layout bounce when textarea content exceeds container */
    contain: layout style;
}
.step-text-input {
    overflow-y: auto;
    min-height: 44px;
    max-height: 160px;
}
.step-row.step-drag-over,
.branch-group.step-drag-over {
    border-top: 3px solid var(--accent);
    border-radius: 0.5rem;
    background-color: var(--accent-dim);
}
.step-drag-handle:hover {
    opacity: 0.7;
}

/* ── Ingredient Selection State ── */
.ingredient-row.ingredient-resolved .ingredient-search-input {
    border-color: var(--primary) !important;
    background: var(--success-bg) !important;
}
.ingredient-row.ingredient-unresolved .ingredient-search-input {
    border-color: var(--error-text) !important;
    background: var(--error-bg) !important;
}

/* ── Spin animation for loading spinners ── */
.animate-spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Shadow float (for elevated buttons) ── */
.shadow-float {
    box-shadow: 0 4px 14px -3px rgba(0, 0, 0, 0.15);
}
.shadow-soft {
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.08);
}

/* ── Mobile Bottom Navigation Bar ── */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s ease;
    min-width: 64px;
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item i {
    font-size: 22px;
}
.mobile-nav-item span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.mobile-nav-item.active {
    color: var(--primary);
}
.mobile-nav-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background-color: #F97316;
    color: white;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* ── Recipe Pagination ── */

.page-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}
.page-dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}
.page-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.page-nav-btn:hover:not(:disabled) {
    background: var(--primary-dim);
    color: var(--primary);
    border-color: var(--primary);
}
.page-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ── Import Disclaimer Banner ── */
.import-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: rgba(224, 122, 95, 0.1);
    border: 1px solid rgba(224, 122, 95, 0.3);
    border-radius: 0.75rem;
    color: var(--text-main);
    font-size: 0.8rem;
    line-height: 1.4;
}
.import-disclaimer > i:first-child {
    color: var(--accent);
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.import-disclaimer > span { flex: 1; }
.import-disclaimer > button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.import-disclaimer > button:hover { color: var(--text-main); }

/* AI validation section — shown below import disclaimer for Plus/Pro */
.ai-validation-section {
    margin-bottom: 1rem;
}
.ai-validation-section details summary {
    list-style: none;
}
.ai-validation-section details summary::-webkit-details-marker {
    display: none;
}
.ai-validation-section details[open] summary {
    border-bottom: 1px solid var(--border);
}

/* Bottom padding on mobile so content isn't hidden behind the nav bar */
@media (max-width: 767px) {
    main { padding-bottom: 80px !important; }
    footer { padding-bottom: 80px !important; }
}
