:root {
    /* =========================
     Primary
  ========================= */
    --m3-p: #6750a4;
    --m3-on-p: #ffffff;

    --m3-p-c: #eaddff;
    --m3-on-p-c: #21005d;

    --m3-p-fixed: #eaddff;
    --m3-on-p-fixed: #21005d;
    --m3-p-fixed-dim: #d0bcff;
    --m3-on-p-fixed-var: #4f378b;

    /* =========================
     Secondary
  ========================= */
    --m3-s: #625b71;
    --m3-on-s: #ffffff;

    --m3-s-c: #e8def8;
    --m3-on-s-c: #1d192b;

    --m3-s-fixed: #e8def8;
    --m3-on-s-fixed: #1d192b;
    --m3-s-fixed-dim: #ccc2dc;
    --m3-on-s-fixed-var: #4a4458;

    /* =========================
     Tertiary
  ========================= */
    --m3-t: #7d5260;
    --m3-on-t: #ffffff;

    --m3-t-c: #ffd8e4;
    --m3-on-t-c: #31111d;

    --m3-t-fixed: #ffd8e4;
    --m3-on-t-fixed: #31111d;
    --m3-t-fixed-dim: #efb8c8;
    --m3-on-t-fixed-var: #633b48;

    /* =========================
     Error
  ========================= */
    --m3-err: #b3261e;
    --m3-on-err: #ffffff;

    --m3-err-c: #f9dedc;
    --m3-on-err-c: #410e0b;

    /* =========================
     Background
  ========================= */
    --m3-bg: #fef7ff;
    --m3-on-bg: #1d1b20;

    /* =========================
     Surface
  ========================= */
    --m3-surf: #f6f2f7;
    --m3-on-surf: #1d1b20;
    --m3-on-surf-var: #49454f;

    --m3-surf-dim: #ded8e1;
    --m3-surf-bright: #fef7ff;
    --m3-surf-elevated: #ffffff;

    /* =========================
     Surface Containers (M3)
  ========================= */
    --m3-surf-c-lowest: #ffffff;
    --m3-surf-c-low: #f7f2fa;
    --m3-surf-c: #f3edf7;
    --m3-surf-c-high: #ece6f0;
    --m3-surf-c-highest: #e6e0e9;

    /* =========================
     Outline
  ========================= */
    --m3-out: #79747e;
    --m3-out-var: #c4c7c5;

    /* =========================
     Inverse
  ========================= */
    --m3-inv-surf: #322f35;
    --m3-inv-on-surf: #f5eff7;
    --m3-inv-p: #d0bcff;
    --m3-on-inv-p: #381e72;

    /* =========================
     Scrim & Shadow
  ========================= */
    --m3-scrim: rgba(0, 0, 0, 0.32);
    --m3-shadow: rgba(0, 0, 0, 0.15);

    /* =========================
     State Layers (Opacity Tokens)
     Use with currentColor
  ========================= */
    --m3-state-hover: 0.08;
    --m3-state-focus: 0.12;
    --m3-state-pressed: 0.12;
    --m3-state-dragged: 0.16;
    --m3-state-disabled: 0.38;

    /* =========================
     Utility / Motion / Effects
  ========================= */
    --ease-emphasized: cubic-bezier(0.3, 0, 0, 1);
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --ease-decelerated: cubic-bezier(0, 0, 0, 1);
    --ease-accelerated: cubic-bezier(0.3, 0, 1, 1);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);

    --glass: blur(20px) saturate(180%);
}



.profile-circle {
    width: 40px;
    height: 40px;
    background: var(--m3-p-c);
    /* Light Purple */
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-weight: bold;
    color: var(--m3-p);
    /* Dark Purple Text */
    text-transform: uppercase;
    flex-shrink: 0;
    /* Prevents it from being crushed if title is long */
}

body {
    background: var(--m3-surf);
    font-family: 'Google Sans Text', sans-serif;
    margin: 0;
    color: #1d1b20;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Dropdown Menu Container */
.profile-dropdown {
    display: none;
    position: absolute;
    top: 70px;
    /* Positioned below the top bar */
    right: 20px;
    width: 240px;
    background: var(--m3-surf-elevated);
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transform-origin: top right;
    animation: menuIn 0.2s var(--ease-emphasized);
}

@keyframes menuIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Dropdown Items */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s;
    color: #1d1b20;
    font-size: 0.95rem;
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.menu-item .material-symbols-rounded {
    color: var(--m3-p);
}

.menu-divider {
    height: 1px;
    background: var(--m3-out-var);
    opacity: 0.3;
    margin: 4px 0;
}

.modal-overlay {
    display: none;
    /* Controlled by JS */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    /* We override this to 'flex' in JS */
    align-items: center;
    justify-content: center;
}

/* Profile UI Additions */
.profile-comp-container {
    text-align: center;
}

.avatar-wrapper {
    position: relative;
    width: 84px;
    height: 84px;
    margin: 0 auto 16px;
}

.avatar-main {
    width: 100%;
    height: 100%;
    background: var(--m3-p);
    color: white;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 2.2rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.2);
}

.avatar-edit-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--m3-out-var);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page {
    position: fixed;
    inset: 0;
    padding: 0 20px 40px 20px;
    transition: transform 0.5s var(--ease-emphasized), opacity 0.4s ease;
    overflow-y: auto;
    background: var(--m3-surf);
    z-index: 10;
}

.page-hidden {
    transform: scale(0.96) translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.top-app-bar {
    display: flex;
    flex-direction: row;
    /* Ensure horizontal flow */
    align-items: center;
    /* Vertically center items */
    justify-content: space-between;
    /* Pushes Title to Left, Profile to Right */
    padding: 12px 20px;
    position: sticky;
    top: 0;
    background: rgba(246, 242, 247, 0.8);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    z-index: 100;
    margin: 0;
    /* Remove negative margins if they exist */
    box-sizing: border-box;
    /* Ensures padding doesn't break width */
    width: 100%;
}

.m3-card {
    background: var(--m3-surf-elevated);
    border-radius: 28px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.m3-card:active {
    transform: scale(0.98);
}

.search-container {
    background: white;
    border-radius: 16px;
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.search-container input {
    border: none;
    background: transparent;
    outline: none;
    height: 48px;
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
}

.chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 20px;
    scrollbar-width: none;
}

.chip {
    padding: 10px 20px;
    border-radius: 12px;
    background: white;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--m3-out);
    border: 1px solid var(--m3-out-var);
    cursor: pointer;
    flex-shrink: 0;
}

.chip.active {
    background: var(--m3-on-p-c);
    color: white;
    border-color: var(--m3-on-p-c);
}

.m3-btn {
    background: var(--m3-p);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
    justify-content: center;
}

.rating-badge {
    background: var(--m3-p-c);
    color: var(--m3-on-p-c);
    padding: 12px 20px;
    border-radius: 20px;
    text-align: center;
}

.stat-box {
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.label-meta {
    color: var(--m3-out);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.star-input span {
    font-size: 38px;
    color: var(--m3-out-var);
    cursor: pointer;
}

.star-input span.active {
    color: #FFB300;
    font-variation-settings: 'FILL' 1;
}

.legal-footer {
    padding: 32px 20px 60px 20px;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    margin-top: 20px;
}

.legal-text {
    font-size: 0.7rem;
    color: var(--m3-out);
    line-height: 1.5;
}

/* Review Card Styles */
.review-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    margin-bottom: 8px;
    align-items: flex-start;
}

.review-avatar {
    width: 32px;
    height: 32px;
    background: var(--m3-p-c);
    color: var(--m3-p);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
}

.review-content {
    flex: 1;
    min-width: 0;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.review-user {
    font-weight: 700;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.review-time {
    font-size: 0.65rem;
    color: var(--m3-out);
}

.review-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #1d1b20;
}

.coffee-btn-bar {
    background: #FFDD00;
    color: #000000;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
    margin-left: auto;
    /* Push to the right before profile */
    margin-right: 8px;
    /* Added spacing between button and profile circle */
}

.coffee-btn-bar:active {
    transform: scale(0.95);
}

.coffee-btn-bar .material-symbols-rounded {
    font-size: 20px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    /* More modern squircle shape */
    border: 1px solid rgba(0, 0, 0, 0.04);
    background: var(--m3-surf-elevated);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.25s var(--ease-emphasized);
    flex-shrink: 0;
    color: var(--m3-p);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.icon-btn:hover {
    background: var(--m3-p-c);
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.15);
}

.icon-btn:active {
    transform: scale(0.92) translateY(0);
    background: rgba(103, 80, 164, 0.2);
}

.icon-btn .material-symbols-rounded {
    font-size: 22px;
    transition: transform 0.2s ease;
}

.icon-btn:hover .material-symbols-rounded {
    transform: scale(1.1);
}


#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #322f35;
    color: #f5eff7;
    padding: 12px 24px;
    border-radius: 28px;
    font-size: 0.9rem;
    z-index: 2000;
    transition: transform 0.3s var(--ease-emphasized);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Review Card Styling */
.review-card {
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.review-card:last-child {
    border-bottom: none;
}

.review-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--m3-p-c);
    color: var(--m3-p);
    display: grid;
    place-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.review-content {
    flex: 1;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.review-date {
    font-size: 0.7rem;
    color: var(--m3-out);
    font-weight: 500;
}

.review-text {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #1d1b20;
}

.full-review-item {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.full-review-item:last-child {
    border-bottom: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--m3-out-var);
    border-radius: 10px;
}

#modalOverlaySuggestion {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: #fff;
    border-radius: 28px;
    padding: 32px 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #79747e;
    cursor: pointer;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input,
textarea {
    padding: 14px;
    border: 1px solid #c4c7c5;
    border-radius: 16px;
    outline: none;
    font-size: 0.95rem;
}

input:focus,
textarea:focus {
    border-color: #6750a4;
    box-shadow: 0 0 0 2px rgba(103, 80, 164, 0.2);
}

.send-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 16px;
    background-color: #6750a4;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
}

.send-btn:hover {
    background-color: #523b91;
}


.toast-error {
    display: none;
    background: #b00020;
    color: #fff;
    padding: 12px 16px;
    border-radius: 16px;
    font-weight: 600;
    text-align: center;
    margin-top: 12px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Success card */
.success-card {
    text-align: center;
    background: #fff;
    border-radius: 28px;
    padding: 40px 24px;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: zoomIn 0.25s ease-out;
}

@keyframes zoomIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.owner-name {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.owner-icon {
    font-size: 18px;
    color: #f4b400;
    font-variation-settings:
        'FILL' 1,
        'wght' 400,
        'GRAD' 0,
        'opsz' 20;
}

.material-symbols-outlined {
    font-size: 16px !important;
    color: #f4b400;
    vertical-align: middle;
    margin: 0px;
    padding: 0;
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 12
}

.owner-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    white-space: nowrap;
    /* prevent line breaks */
    overflow-x: auto;
    /* allow horizontal scrolling if needed */
    -webkit-overflow-scrolling: touch;
    /* smooth scroll on mobile */
}

.owner-badge .crown {
    font-size: 0.85em;
    line-height: 1;
    vertical-align: middle;
    color: #FFC107;
    display: inline-flex;
}

.info-btn-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 14px;
    height: 14px;
    border-radius: 25px;

    background: var(--m3-t);
    /* authoritative blue, not some weak grey */
    color: var(--m3-on-t);

    font-weight: 600;
    text-decoration: none;

    margin: 10px 10px 10px 0;

    transition: background 0.2s ease, transform 0.1s ease;
}

.info-btn-bar:hover {
    background: var(--m3-t-c);
    color: var(--m3-on-t-c);

    transform: translateY(-1px);
}

.info-btn-bar .material-symbols-rounded {
    font-size: 20px;
}

.m3-btn-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 14px;
    height: 14px;
    border-radius: 25px;

    background: var(--m3-s);
    /* authoritative blue, not some weak grey */
    color: var(--m3-on-s);

    font-weight: 600;
    text-decoration: none;

    margin: 10px 10px 10px 0;

    transition: background 0.2s ease, transform 0.1s ease;
}

.m3-btn-bar:hover {
    background: var(--m3-s-c);
    color: var(--m3-on-s-c);

    transform: translateY(-1px);
}

.m3-btn-bar .material-symbols-rounded {
    font-size: 20px;
}

/*MODAL*/
/* --- Add Info Modal enhancements (M3-ish) --- */
.m3-dialog h2 {
    margin: 0 0 14px 0;
    font-family: "Google Sans";
    letter-spacing: -0.2px;
}

.m3-subtitle {
    margin: 0 0 18px 0;
    color: #49454f;
    font-size: 0.9rem;
    line-height: 1.4;
}

.m3-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 520px) {
    .m3-grid-2 {
        grid-template-columns: 1fr;
    }
}

.m3-field input,
.m3-field textarea,
.m3-field select {
    outline: none;
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.m3-field input:focus,
.m3-field textarea:focus,
.m3-field select:focus {
    border-color: var(--m3-p);
    box-shadow: 0 0 0 4px rgba(103, 80, 164, 0.18);
    background: rgba(103, 80, 164, 0.04);
}

.m3-hint {
    margin: 8px 6px 0 6px;
    font-size: 0.78rem;
    color: var(--m3-out);
}

.m3-error {
    margin: 10px 6px 0 6px;
    font-size: 0.82rem;
    color: var(--m3-err);
    font-weight: 600;
    display: none;
}

.m3-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 18px 0;
}

/*Info Button*/

.info-btn-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 14px;
    margin: 10px 10px 10px 0;

    border-radius: 25px;

    background: var(--m3-t);
    /* authoritative blue, not some weak grey */
    color: var(--m3-on-t);

    font-weight: 600;
    text-decoration: none;

    transition: background 0.2s ease, transform 0.1s ease;
}

.info-btn-bar:hover {
    background: var(--m3-t-c);
    color: var(--m3-on-t-c);
    transform: translateY(-1px);
}

.info-btn-bar .material-symbols-rounded {
    font-size: 20px;
}

/* ===== Mobile friendly stacked top app bar ===== */

.top-app-bar--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* First row: title/back + profile */
.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.topbar-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Back button styling to match */
.topbar-back {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--m3-p);
}

.topbar-back:active {
  transform: scale(0.96);
}

/* Desktop: single row as usual */
.topbar-responsive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Mobile: wrap actions below title cleanly */
@media (max-width: 520px) {
  .topbar-responsive {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .topbar-title {
    flex: 1 1 100%;
  }

  .topbar-actions {
    width: 100%;
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Make all action buttons smaller */
  .topbar-actions .coffee-btn-bar,
  .topbar-actions .info-btn-bar,
  .topbar-actions .m3-btn-bar {
    padding: 8px 12px;
    border-radius: 999px;
    margin: 0;             /* neutralize existing margins */
    font-size: 0.8rem;
  }

  /* Keep icons tight */
  .topbar-actions .material-symbols-rounded {
    font-size: 20px;
  }

  /* Optional: hide labels if it still feels cramped */
  .topbar-actions .btn-label {
    display: none;
  }

  /* Keep profile visible and aligned */
  .topbar-actions .profile-circle {
    width: 38px;
    height: 38px;
  }
}
