/* Universal Box Sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* General Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f1ea;
    color: #444;
    line-height: 1.6;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: #5c001f;
    color: #fff;
    text-align: center;
    padding: 0.7rem 1rem; /* Reduced vertical padding */
    position: sticky; /* Makes the header 'freeze' on scroll */
    top: 0;
    z-index: 100; /* Ensures header stays on top of other content */

    /* Center header contents (brand row + tagline) */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Ensure header is a positioning context */
header {
  position: relative;
}

header {
    display: flex;
    justify-content: center; /* center the whole brand row */
    align-items: center;
    text-align: center;      /* center text inside the brand-text block */
}

/* Brand row: center logo + title horizontally */
.site-brand {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* left spacer | centered text | right spacer */
    align-items: center;
    column-gap: 12px;
    width: 100%;
}

.site-logo {
    grid-column: 1;          /* left spacer column */
    justify-self: end;       /* hug the centered text */
    width: 84px;   /* was 56px */
    height: 84px;  /* was 56px */
    object-fit: cover;
    border-radius: 8px;
}

.brand-text {
    grid-column: 2;          /* centered column */
    display: flex;
    flex-direction: column;
    align-items: center;     /* keep both lines centered */
    text-align: center;
    gap: 2px;
    margin: 0;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    /* REMOVED: width: 100%; */
}

.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    margin-bottom: 1rem;
}

/* Form Styling */
.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

input[type="text"], input[type="file"], input[type="password"], input[type="email"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* General button reset */
button {
    font-family: inherit;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 0.75rem; /* Add default padding */
}

/* Style for primary, full-width action buttons */
#login-btn, #signup-btn, #submit-btn {
    width: 100%;
    padding: 1rem;
    background-color: #5c001f;
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
    position: relative; /* for spinner positioning */
}

button:disabled {
    background-color: #8e8e8e; /* clearer disabled color */
    cursor: not-allowed;
    opacity: 0.9;
}

#login-btn:hover:not(:disabled),
#signup-btn:hover:not(:disabled),
#submit-btn:hover:not(:disabled) {
     background-color: #8c0032;
}

/* Loading state for the Evaluate button */
#submit-btn.loading {
    background-color: #7a7a7a; /* distinct loading color */
}

#submit-btn.loading::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.6);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Results and Ads */
#results-body > p {
    margin: 0.5rem 0; /* tighter spacing for concise layout */
}

/* Compact separators between result sections */
#results-body > *:not(:first-child) {
    border-top: 1px solid #eee;
    padding-top: 6px;
    margin-top: 4px;
}

#summary-row {
    margin-top: calc(1rem + 9px);
}

#error {
    color: #D32F2F;
    background-color: #FFCDD2;
    padding: 15px;
    border-radius: 5px;
}

#reasoning-details {
    margin-top: 1.5rem;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 5px;
}

#reasoning-details summary {
    cursor: pointer;
    font-weight: bold;
    padding: 0.75rem;
}

.reasoning-content {
    padding: 0 0.75rem 0.75rem 0.75rem;
    border-top: 1px solid #eee;
}

#purchase-rating-bubble {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Price Bar Styles */
#price-range-container {
    margin: 1.5rem 0;
}

.price-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.price-bar {
    flex-grow: 1;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #2ECC71, #F1C40F, #E74C3C);
    position: relative;
}

.price-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background-color: #fff;
    border: 3px solid #5c001f;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.price-value {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9em;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
}

.price-label {
    font-size: 0.8em;
    color: #666;
    font-weight: 500;
}

footer {
    text-align: center;
    padding: 1rem;
    background: #e9e9e9;
    /* REMOVED: width: 100%; */
}

.separator {
    text-align: center;
    margin: 1rem 0 0.5rem 0;
    color: #888;
}

.google-btn {
    background-color: #fff !important;
    color: #444 !important;
    border: 1px solid #ccc !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    width: auto;
    align-self: center;
    height: 46px;
    box-sizing: border-box;
}

.google-btn img {
    height: 24px;
    width: 24px;
}

/* Auth Panel */
.auth-form-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Creates consistent vertical space */
}

.auth-form-content > h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 600;
}

/* Override margins now that flex-gap handles spacing */
.auth-form-content .separator,
.auth-form-content .auth-toggle {
    margin: 0;
}

.auth-form-content #password-input {
    margin-bottom: 0.5rem; /* Add a bit of space before the login button */
}

.auth-toggle {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-top: 1.5rem !important;
}

.auth-toggle a {
    color: #5c001f;
    font-weight: bold;
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* --- UPDATED: Header User Menu Styles --- */
#user-menu {
    position: absolute;
    top: 50%; /* Center vertically in the header */
    transform: translateY(-50%);
    left: 1rem;
    z-index: 10;
}

#user-menu summary {
    list-style: none; /* Remove default marker */
    cursor: pointer;
    padding: 0.5rem; /* Add some touch area */
    display: inline-block;
    line-height: 0; /* Helps with vertical alignment */
}

#user-menu summary::-webkit-details-marker {
    display: none; /* Hide marker for Webkit browsers */
}

.hamburger-icon {
    fill: #fff; /* White bars for the hamburger */
}

.user-menu-panel {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-top: 0.5rem;
    padding: 0.5rem;
    position: absolute;
    width: 220px; /* A bit wider to accommodate email */
}

/* Style for the email display inside the panel */
.user-menu-panel .user-email-display {
    padding: 0.75rem;
    font-weight: bold;
    color: #333;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.5rem;
    word-break: break-all; /* Prevents long emails from breaking the layout */
}

.user-menu-panel button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #444;
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 4px;
}

.user-menu-panel button:hover {
    background-color: #f4f1ea;
}

.user-menu-panel button.logout {
    color: #E74C3C;
}

.user-menu-panel button.danger,
button.danger {
  color: #B00020;
  background: #FFF5F6;
  border: 1px solid #F3C2C2;
}
.user-menu-panel button.danger:hover,
button.danger:hover {
  background: #FFE9EB;
}

/* --- End Header Menu Styles --- */

#app-content {
    width: 100%;
    max-width: 500px;
    padding: 0;
}

/* Utility: visually hidden (accessible to screen readers) */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap; /* prevent the text from wrapping */
    border: 0;
}

.wine-name {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    line-height: 1.2;
    font-weight: 700;
    color: #333;
    display: -webkit-box;
    display: box; /* fallback */
    -webkit-line-clamp: 2; /* clamp to 2 lines by default */
    line-clamp: 2; /* standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Optional expand control */
.wine-name.expand {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

.wine-name-toggle {
    display: none;
    color: #5c001f;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.site-brand {
    display: flex;
    align-items: center;
    justify-content: center; /* center the logo + title */
    gap: 0.5rem;
    margin: 0 auto;
}

.site-logo {
    width: 84px;   /* was 56px */
    height: 84px;  /* was 56px */
    object-fit: cover;
    border-radius: 8px;
}

@media (max-width: 480px) {
    /* Slightly smaller on very small screens if needed */
    .site-logo {
        width: 78px;  /* was 52px */
        height: 78px; /* was 52px */
    }
}

@media (max-width: 600px) {
    .wine-name { font-size: 1.15rem; }
}

/* Header Actions: Login/Register buttons + User menu */
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.home-btn {
  position: absolute;
  left: 36px;
  top: 36px;
  display: inline-flex;
  align-items: left;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
}
.home-btn:hover {
  background-color: #b8b7b6;
}
.home-btn:focus-visible {
  outline: 2px solid #5c001f;
  outline-offset: 2px;
  border-radius: 8px;
}
.home-btn svg { display: block; }

.blurred { filter: blur(6px); user-select: none; pointer-events: none; }

.cta-register {
  margin-top: 16px;
  background: #5c001f; color: #fff; border: none;
  padding: 12px 18px; border-radius: 8px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(92,0,31,0.25);
}
.cta-register:hover { background: #6f0a2a; }

/* Make the demo Evaluate button match the main Evaluate button */
#submit-btn,
#demo-submit-btn {
  background: #5c001f;
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(92, 0, 31, 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.02s ease;
}

#submit-btn:hover,
#demo-submit-btn:hover {
  background: #6f0a2a;
}

#submit-btn:disabled,
#demo-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
