/* =========================================================================
   MenuRedux web app styles.
   Mirrors the Android Compose UI (Color.kt / Dimensions.kt) — see js/config.js
   for the matching JS values. Keep this and config.js in sync.
   ========================================================================= */

/* --- reset & base --- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;                /* lock page; no body-level scrolling */
    overscroll-behavior: none;       /* kill pull-to-refresh / chain scrolling */
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #fff;
    background: #2c2c2c;             /* phone view background (mobile) */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: fixed;                 /* iOS: prevents body bounce/rubber-band */
    inset: 0;
    width: 100%;
}
button { font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }

/* --- phone-frame: responsive container --- */
/* Mobile: fills viewport edge-to-edge */
#phone-frame {
    width: 100%;
    height: 100%;                    /* fill locked body, not viewport — prevents overflow that triggers iOS bounce */
    background: #2c2c2c;             /* backgroundGrey */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Desktop / tablet: constrain to phone-sized column, center, dark margins */
@media (min-width: 480px) {
    body { background: #1a1a1a; }    /* darker margins outside the phone */
    #phone-frame {
        max-width: 420px;
        margin: 0 auto;
        box-shadow: 0 0 24px rgba(0,0,0,0.6);
    }
}

/* --- screen visibility (one at a time) --- */
.screen          { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.screen.hidden   { display: none; }

/* =========================================================================
   TopBar — fixed 128px header. Mirrors ui/components/TopBar.kt.
   ========================================================================= */
.topbar {
    height: 128px;
    background: #333333;             /* dietprefsGrey */
    display: flex;
    align-items: center;
    padding: 12px 16px;
    position: relative;
    flex-shrink: 0;
}
.topbar-back {
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    margin-left: -8px;
    color: #fff;
    font-size: 24px;
    line-height: 1;
}
.topbar-empty-title {
    font-size: 40px;
    font-weight: bold;
    color: #E06666;                  /* user1Red */
    margin: 0 0 0 8px;
}
.topbar-users {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    padding-left: 16px;
    overflow: hidden;
}
.topbar-user {
    display: flex;
    align-items: center;            /* icon + text-span on the same horizontal axis */
    gap: 8px;
    font-size: 20px;
    font-weight: bold;
    overflow: hidden;
}
.topbar-user.u1 { color: #E06666; }   /* user1Red */
.topbar-user.u2 { color: #E0B3FF; }   /* user2Magenta */
.topbar-user-icon {
    padding: 4px;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    /* Visual nudge: text glyphs sit slightly below their box center, SVG sits at center.
     * Without this, the icon looks ~2-3px high relative to the text glyph mass. */
    margin-top: 3px;
}
/* Multi-line truncation on the text span only (Android: 4 lines solo / 2 lines two-user).
 * Kept in a nested span so the parent .topbar-user can stay flex-horizontal
 * (display:-webkit-box on the parent would stack icon ABOVE text — wrong). */
.topbar-user-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.topbar-users.two-user .topbar-user-text { -webkit-line-clamp: 2; }
/* Inline SVG person icon — inherits text color via currentColor */
.person-icon { display: inline-flex; align-items: center; }
.person-icon svg { width: 22px; height: 22px; display: block; }
.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}
.topbar-settings {
    background: none;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    padding: 4px 8px;
}

/* =========================================================================
   PreferenceScreen
   ========================================================================= */
.prefs-body {
    background: #2C2C2C;             /* backgroundGrey */
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;                        /* vertical gap between grid and final row (Android Column spacedBy(3.dp)) */
    padding: 4px 0;
    overflow: hidden;
}
.prefs-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;                        /* GRID_SPACING */
    flex: 16;                        /* 16 rows : 1 final row */
    /* No horizontal padding: tiles extend edge-to-edge, matching Android */
}
.prefs-row {
    display: flex;
    gap: 3px;
    flex: 1;
}
.pref-tile {
    flex: 1;
    background: #333333;             /* dietprefsGrey */
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0 12px;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    min-height: 0;
    display: flex;
    align-items: center;
}
.pref-tile.teal              { background: #004D4D; }
.pref-tile.selected          { background: #595959; }
.pref-tile.teal.selected     { background: #008080; }

/* row 17: low price + user toggle.
 * CSS Grid (not flex) here: `1fr 1fr` guarantees exact 50/50 columns
 * regardless of children's display/content. Earlier flex + min-width:0
 * approach was foiled by display:flex on .btn-user-toggle causing it
 * to shrink-to-fit in some browsers. */
.prefs-row-final {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    flex: 1;
}
.btn-low-price {
    flex: 1;
    min-width: 0;                    /* override default content-based min-width so flex distributes strictly equally */
    background: #333333;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0 12px;
    text-align: left;
    font-size: 16px;
    cursor: pointer;
}
.btn-low-price.selected { background: #595959; }
.btn-user-toggle {
    flex: 1;
    min-width: 0;
    background: #333333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-user-toggle.active { background: #595959; }
.btn-user-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

/* bottom bar: Search + Clear */
.prefs-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #333333;
    padding: 4px;
    flex-shrink: 0;
}
.btn-search {
    flex: 1;
    background: transparent;
    border: none;
    color: #E06666;                  /* user1Red */
    font-size: 32px;
    cursor: pointer;
    padding: 8px;
}
.btn-clear {
    background: #B35100;             /* clearOrange */
    color: #fff;
    font-size: 20px;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    margin: 8px;
    cursor: pointer;
}

/* =========================================================================
   PriceSelectionDialog (modal)
   ========================================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-backdrop.hidden { display: none; }
.modal {
    background: #333333;
    border-radius: 8px;
    padding: 16px;
    width: min(360px, calc(100vw - 32px));
    color: #fff;
}
.modal-title { font-size: 20px; font-weight: bold; margin: 0 0 12px 0; }
.price-list { max-height: 264px; overflow-y: auto; }
.price-option {
    width: 100%;
    background: transparent;
    color: #fff;
    border: none;
    border-radius: 4px;
    text-align: left;
    padding: 12px;
    font-size: 16px;
    cursor: pointer;
}
.price-option.selected { background: #595959; }
.price-option:hover { background: rgba(255,255,255,0.05); }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}
.modal-btn {
    background: none;
    color: #fff;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}
.modal-btn:hover { background: rgba(255,255,255,0.08); }

/* =========================================================================
   SearchResultsScreen
   ========================================================================= */
.results-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #2C2C2C;
    padding-top: 4px;
    min-height: 0;
}
.results-header {
    background: #333333;
    padding: 8px 0;
    flex-shrink: 0;
}
.results-header-row {
    display: flex;
    align-items: center;
}
.results-header-col { display: flex; align-items: center; cursor: pointer; padding: 4px 0; }
.results-header-col.vendors   { flex: 2; padding-left: 16px; }
.results-header-col.distance  { flex: 1; justify-content: center; }
.results-header-col.items     { flex: 1; justify-content: center; padding-right: 8px; }
.results-header-col .label {
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    font-weight: normal;
    white-space: nowrap;
}
.results-header-col.selected .label {
    color: #fff;
    font-weight: bold;
}
.results-header-meta {
    display: flex;
    align-items: center;
    margin-top: 4px;
}
.results-meta-count {
    flex: 2;
    text-align: right;
    padding-right: 16px;
    font-size: 11px;
    color: #fff;
}
.results-meta-spacer { flex: 1; }
.results-meta-icons {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}
/* Override default 22px sizing for these smaller user-mode dots (Android: 16dp) */
.results-meta-icons .person-icon svg { width: 16px; height: 16px; }

/* List holder claims remaining space whether it's populated (.vendor-list)
 * or showing the empty state. Without flex:1 here, the empty-state collapses
 * and the search bar + filter buttons jump up from the bottom. */
.h-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.vendor-list {
    overflow-y: auto;
}
.vendor-row {
    display: flex;
    height: 48px;
    cursor: pointer;
    border-bottom: 2px solid #2C2C2C;
}
.vendor-row:last-child { border-bottom: none; }
.vendor-name-cell {
    flex: 2;
    position: relative;
    /* rating background — gradient applied via inline style */
    background: linear-gradient(to right, #416831 0%, #416831 0%, #333333 0%, #333333 100%);
}
.vendor-name {
    position: absolute;
    top: 6px; left: 12px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
}
.vendor-rating-text {
    position: absolute;
    top: 22px; right: 16px;
    font-size: 11px;
    color: #fff;
}
.vendor-distance-cell {
    flex: 1;
    background: #333333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.vendor-items-cell {
    flex: 1;
    background: #333333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-align: center;
}
.vendor-items-cell.custom-by-nature { background: #CC9900; }

.results-search-bar {
    background: #333333;
    padding: 4px;
    flex-shrink: 0;
}
.results-search-input {
    width: 100%;
    border: none;
    background: #F0F0F0;
    color: #000;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
}
.results-search-input:focus { outline: none; }

.filter-buttons {
    background: #333333;
    padding: 6px 12px 12px 12px;
    flex-shrink: 0;
}
.filter-row {
    display: flex;
    justify-content: space-evenly;
    gap: 4px;
}
.filter-row + .filter-row { margin-top: 8px; }
.compact-btn {
    width: 64px;
    height: 40px;
    background: #2C2C2C;
    color: #fff;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
}
.compact-btn.selected {
    border-color: #008080;
    background: rgba(0,128,128,0.3);
}
/* Invisible slot — keeps row positions fixed when a service URL is missing
 * (so e.g. "Doordash" and "Yelp" always sit in the same column). */
.compact-btn.placeholder {
    visibility: hidden;
    pointer-events: none;
    box-shadow: none;
    border-color: transparent;
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #ccc;
    padding: 16px;
}

/* =========================================================================
   RestaurantDetailScreen
   ========================================================================= */
.detail-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #2C2C2C;
    padding-top: 4px;
    min-height: 0;
}
.detail-viewport {
    height: 204px;
    overflow-y: auto;
    flex-shrink: 0;
    /* allow last item to be scrolled to top of the viewport (matches Android BOTTOM_PADDING) */
    padding-bottom: 156px;
    /* CRITICAL: makes this the offsetParent of .detail-row children.
     * Without it, target.offsetTop (used by _scrollSelectedToSecond in detail.js)
     * is measured from <body>, so scrollTo over-scrolls past the clicked row. */
    position: relative;
}

/* "No photos" layout: when an item is selected and has no pictures, hide the
 * (empty) card-top and let the menu list grow into that freed space rather
 * than enlarging the voting/description boxes below. JS toggles `.no-photos`
 * on .detail-body. */
.detail-body.no-photos .detail-viewport {
    height: auto;
    flex: 1 1 0;
    min-height: 0;
}
.detail-body.no-photos .dynamic-card {
    flex: 0 0 auto;                 /* size to card-bottom's content only */
}
.detail-body.no-photos .card-top {
    display: none;
}
.detail-body.no-photos .card-bottom {
    flex: 0 0 auto;                 /* don't stretch — intrinsic content height */
    min-height: 120px;              /* keep voting/description usable */
}
.detail-row {
    border-bottom: 2px solid #2C2C2C;
}
.restaurant-header {
    height: 60px;
    background: #8C6600;             /* restaurantDeselectedGold */
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
}
.restaurant-header.selected { background: #CC9900; }
.restaurant-header-name {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}
.menu-item-row {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
    /* gradient bg applied via inline style */
}
.menu-item-name {
    flex: 1;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.menu-item-user-icons {
    display: flex;
    gap: 4px;
    margin-right: 8px;
}
.menu-item-user-icons .user-dot { width: 12px; height: 12px; border-radius: 50%; }
.menu-item-user-icons .user-dot.u1 { background: #E06666; }
.menu-item-user-icons .user-dot.u2 { background: #E0B3FF; }
.menu-item-price {
    width: 60px;
    text-align: right;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.dynamic-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #2C2C2C;
}

/* Restaurant/Item card layout.
 * card-bottom is intrinsic (~120px sized to its info boxes) so the bottom
 * row stays consistent across all three view states (restaurant, item with
 * photos, item without photos). card-top absorbs whatever space remains. */
.card-top {
    flex: 1 1 0;
    min-height: 0;
    background: #333333;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}
.card-top.map-area {
    display: flex;
    align-items: center;
    justify-content: center;
}
.map-placeholder { text-align: center; }
.map-placeholder .icon { font-size: 48px; }
.map-placeholder .label { color: rgba(255,255,255,0.7); font-size: 14px; }
.directions-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(44,44,44,0.9);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.expanded-hours {
    height: 100%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    cursor: pointer;
}
.expanded-hours-status { text-align: center; font-size: 18px; }
.expanded-hours-status.open { color: #4CAF50; }
.expanded-hours-status.closed { color: #E57373; }
.expanded-hours-row {
    display: flex;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 14px;
}
.expanded-hours-row .day { color: rgba(255,255,255,0.9); }
.expanded-hours-row .hrs { color: #ccc; }

.card-bottom {
    flex: 0 0 auto;                 /* intrinsic content height — consistent across views */
    min-height: 120px;
    display: flex;
    gap: 8px;
    padding: 8px;
}
.info-box {
    background: #333333;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 8px;
}
.mini-map-box, .condensed-hours-box {
    flex: 2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-map-box .icon { font-size: 24px; }
.mini-map-box .label { color: rgba(255,255,255,0.7); font-size: 11px; }
.condensed-hours-box { flex-direction: column; padding: 8px; }
.condensed-status { text-align: center; font-size: 14px; padding: 1px 0; }
.condensed-status.open { color: #4CAF50; }
.condensed-status.closed { color: #E57373; }
.condensed-hours-row {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
    font-size: 12px;
}
.condensed-hours-row .day { color: rgba(255,255,255,0.9); }
.condensed-hours-row .hrs { color: #ccc; }

.details-box {
    flex: 3;
    display: flex;
    gap: 8px;
    font-size: 12px;
}
.details-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.details-tag { color: #ccc; padding: 1px 0; }
.details-rating { color: rgba(255,255,255,0.9); padding: 1px 0; }
.details-address { color: rgba(255,255,255,0.9); padding: 1px 0; }

/* Item card */
.photo-carousel {
    width: 100%;
    height: 100%;                   /* fills .card-top (was 300px hard-coded) */
    background: #333333;
    position: relative;
    overflow: hidden;
}
.photo-carousel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-carousel-no-photos {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #555;
    color: #fff;
}
.photo-carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.photo-carousel-dot {
    width: 8px; height: 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
}
.photo-carousel-dot.active { background: #fff; }
.photo-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 40px; height: 60px;
    font-size: 24px;
    cursor: pointer;
}
.photo-nav.prev { left: 0; }
.photo-nav.next { right: 0; }

.voting-box {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
}
.voting-icons {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    width: 100%;
}
.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 40px;
    line-height: 1;
    padding: 8px;
}
.vote-btn.up   { color: #5FA048; }
.vote-btn.down { color: #E06666; }
.voting-rating { font-size: 12px; color: #fff; padding-bottom: 4px; }
.item-details-box {
    flex: 3;
    font-size: 12px;
    color: #ccc;
    overflow-y: auto;
}

/* External links grid */
.external-links {
    background: #333333;
    padding: 6px 12px 12px 12px;
    flex-shrink: 0;
}
.external-links .filter-row { gap: 4px; }

/* =========================================================================
   Error snackbar
   ========================================================================= */
.snackbar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 200;
    max-width: 360px;
}
.snackbar.hidden { display: none; }

/* =========================================================================
   Loading spinner
   ========================================================================= */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
