/*
 * Tasting Moments - Wine-Themed Styling
 * Dark, elegant: deep burgundy + cream + gold accents
 * Mobile-first, one-thumb operation
 */

/* =====================================================================
   CSS Variables
   ===================================================================== */
:root {
    /* Wine palette */
    --tm-bg: #1a0f14;
    --tm-bg-light: #2a1a22;
    --tm-bg-card: #33202a;
    --tm-bg-input: #241620;

    --tm-burgundy: #722F37;
    --tm-burgundy-light: #8B3A42;
    --tm-burgundy-dark: #4A1C23;

    --tm-gold: #C5A55A;
    --tm-gold-light: #D4B96E;
    --tm-gold-dim: #8B7640;

    --tm-cream: #F5E6D3;
    --tm-cream-dim: #C4B09A;
    --tm-cream-dark: #9A8672;

    --tm-white: #FAF5EF;
    --tm-white-dim: rgba(250, 245, 239, 0.6);

    /* Wine colors */
    --tm-red-wine: #722F37;
    --tm-white-wine: #F0E68C;
    --tm-rose-wine: #E8A0B4;
    --tm-sparkling-wine: #F5E6B8;

    /* Typography */
    --tm-font-display: 'Cormorant Garamond', Georgia, serif;
    --tm-font-body: 'Inter', -apple-system, sans-serif;

    /* Spacing */
    --tm-space-xs: 0.25rem;
    --tm-space-sm: 0.5rem;
    --tm-space-md: 1rem;
    --tm-space-lg: 1.5rem;
    --tm-space-xl: 2rem;
    --tm-space-xxl: 3rem;

    /* Borders */
    --tm-radius: 12px;
    --tm-radius-sm: 8px;
    --tm-radius-lg: 20px;
}

/* =====================================================================
   Reset & Base
   ===================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--tm-font-body);
    background: var(--tm-bg);
    color: var(--tm-cream);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 640px;
    margin: 0 auto;
}

/* =====================================================================
   Header
   ===================================================================== */
.tm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tm-space-md) var(--tm-space-lg);
    border-bottom: 1px solid rgba(197, 165, 90, 0.15);
}

.tm-logo {
    display: flex;
    align-items: center;
    gap: var(--tm-space-sm);
}

.tm-glass {
    font-size: 1.4rem;
}

.tm-brand {
    font-family: var(--tm-font-display);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--tm-gold);
    letter-spacing: 0.02em;
}

.tm-header-right {
    display: flex;
    align-items: center;
    gap: var(--tm-space-md);
}

.tm-step-label {
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--tm-cream-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.tm-new-tasting-btn {
    font-family: var(--tm-font-body);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--tm-cream-dark);
    background: transparent;
    border: 1px solid rgba(197, 165, 90, 0.2);
    border-radius: var(--tm-radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tm-new-tasting-btn:hover {
    color: var(--tm-gold);
    border-color: var(--tm-gold);
}

/* =====================================================================
   Main Content
   ===================================================================== */
.tm-main {
    flex: 1;
    padding: var(--tm-space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--tm-space-lg);
}

/* Loading */
.tm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--tm-space-md);
    padding: var(--tm-space-xxl) 0;
}

.tm-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(197, 165, 90, 0.2);
    border-top-color: var(--tm-gold);
    border-radius: 50%;
    animation: tm-spin 1s ease-in-out infinite;
}

@keyframes tm-spin {
    to { transform: rotate(360deg); }
}

.tm-loading-text {
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--tm-cream-dim);
}

/* Sommelier Message */
.tm-sommelier {
    animation: tm-fadeIn 0.6s ease-out;
}

.tm-message {
    font-family: var(--tm-font-display);
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--tm-cream);
}

.tm-message p {
    margin-bottom: var(--tm-space-md);
}

.tm-message p:last-child {
    margin-bottom: 0;
}

@keyframes tm-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =====================================================================
   Wine Card
   ===================================================================== */
.tm-wine-card {
    display: flex;
    align-items: center;
    gap: var(--tm-space-md);
    background: var(--tm-bg-card);
    border: 1px solid rgba(197, 165, 90, 0.15);
    border-radius: var(--tm-radius);
    padding: var(--tm-space-md);
    animation: tm-fadeIn 0.4s ease-out;
}

.tm-wine-color {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(0,0,0,0.3);
}

.tm-color-red { background: radial-gradient(circle, var(--tm-red-wine), #3a1520); }
.tm-color-white { background: radial-gradient(circle, var(--tm-white-wine), #8a7830); }
.tm-color-rosé, .tm-color-rose { background: radial-gradient(circle, var(--tm-rose-wine), #7a3050); }
.tm-color-sparkling { background: radial-gradient(circle, var(--tm-sparkling-wine), #8a7840); box-shadow: 0 0 12px rgba(245, 230, 184, 0.2); }

.tm-wine-info {
    flex: 1;
    min-width: 0;
}

.tm-wine-name {
    font-family: var(--tm-font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--tm-gold-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-wine-detail {
    font-size: 0.8rem;
    color: var(--tm-cream-dim);
    font-weight: 300;
}

/* =====================================================================
   Wine Search
   ===================================================================== */
.tm-search-section {
    display: flex;
    flex-direction: column;
    gap: var(--tm-space-md);
}

.tm-search-box {
    position: relative;
}

.tm-search-input {
    width: 100%;
    padding: var(--tm-space-md) var(--tm-space-lg);
    background: var(--tm-bg-input);
    border: 1px solid rgba(197, 165, 90, 0.3);
    border-radius: var(--tm-radius);
    color: var(--tm-cream);
    font-family: var(--tm-font-body);
    font-size: 1.05rem;
    outline: none;
    transition: border-color 0.2s;
}

.tm-search-input:focus {
    border-color: var(--tm-gold);
}

.tm-search-input::placeholder {
    color: var(--tm-cream-dark);
}

.tm-search-results {
    display: flex;
    flex-direction: column;
    gap: var(--tm-space-xs);
}

.tm-wine-result {
    display: flex;
    align-items: center;
    gap: var(--tm-space-md);
    padding: var(--tm-space-md);
    background: var(--tm-bg-card);
    border: 1px solid rgba(197, 165, 90, 0.1);
    border-radius: var(--tm-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: inherit;
    font: inherit;
    width: 100%;
}

.tm-wine-result:hover, .tm-wine-result:focus {
    border-color: var(--tm-gold);
    background: rgba(197, 165, 90, 0.08);
}

.tm-result-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tm-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tm-result-name {
    font-family: var(--tm-font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--tm-cream);
}

.tm-result-detail {
    font-size: 0.75rem;
    color: var(--tm-cream-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-result-confidence {
    font-size: 0.7rem;
    color: var(--tm-gold-dim);
    font-weight: 500;
}

.tm-search-hint {
    font-size: 0.85rem;
    color: var(--tm-cream-dark);
    font-style: italic;
    text-align: center;
    padding: var(--tm-space-sm);
}

/* =====================================================================
   Tasting Notes
   ===================================================================== */
.tm-notes-section {
    display: flex;
    flex-direction: column;
    gap: var(--tm-space-sm);
    border-top: 1px solid rgba(197, 165, 90, 0.1);
    padding-top: var(--tm-space-md);
}

.tm-notes-header {
    display: flex;
    align-items: baseline;
    gap: var(--tm-space-sm);
}

.tm-notes-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tm-cream-dim);
}

.tm-notes-hint {
    font-size: 0.7rem;
    font-style: italic;
    color: var(--tm-cream-dark);
}

.tm-notes-input {
    width: 100%;
    padding: var(--tm-space-md);
    background: var(--tm-bg-input);
    border: 1px solid rgba(197, 165, 90, 0.2);
    border-radius: var(--tm-radius-sm);
    color: var(--tm-cream);
    font-family: var(--tm-font-body);
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.tm-notes-input:focus {
    border-color: var(--tm-gold-dim);
}

.tm-notes-input::placeholder {
    color: var(--tm-cream-dark);
    font-style: italic;
}

/* =====================================================================
   Step Progress
   ===================================================================== */
.tm-progress {
    display: flex;
    justify-content: center;
    gap: var(--tm-space-lg);
    padding: var(--tm-space-md) var(--tm-space-lg);
    border-top: 1px solid rgba(197, 165, 90, 0.1);
}

.tm-progress-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--tm-space-xs);
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.tm-progress-dot.active {
    opacity: 1;
}

.tm-progress-dot.completed {
    opacity: 0.7;
}

.tm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tm-cream-dark);
    transition: all 0.3s;
}

.tm-progress-dot.active .tm-dot {
    width: 10px;
    height: 10px;
    background: var(--tm-gold);
    box-shadow: 0 0 8px rgba(197, 165, 90, 0.5);
}

.tm-progress-dot.completed .tm-dot {
    background: var(--tm-gold-dim);
}

.tm-dot-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tm-cream-dim);
    font-weight: 300;
}

.tm-progress-dot.active .tm-dot-label {
    color: var(--tm-gold);
}

/* =====================================================================
   Action Bar
   ===================================================================== */
.tm-actions {
    padding: var(--tm-space-md) var(--tm-space-lg) var(--tm-space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--tm-space-sm);
}

/* Buttons */
.tm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tm-space-sm);
    padding: var(--tm-space-md) var(--tm-space-xl);
    border: none;
    border-radius: var(--tm-radius);
    font-family: var(--tm-font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.tm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tm-btn-primary {
    background: linear-gradient(135deg, var(--tm-burgundy), var(--tm-burgundy-dark));
    color: var(--tm-cream);
    border: 1px solid rgba(197, 165, 90, 0.3);
}

.tm-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--tm-burgundy-light), var(--tm-burgundy));
    border-color: var(--tm-gold);
}

.tm-btn-secondary {
    background: transparent;
    color: var(--tm-gold);
    border: 1px solid rgba(197, 165, 90, 0.3);
}

.tm-btn-secondary:hover:not(:disabled) {
    background: rgba(197, 165, 90, 0.08);
    border-color: var(--tm-gold);
}

.tm-btn-ghost {
    background: transparent;
    color: var(--tm-cream-dim);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 300;
}

.tm-btn-ghost:hover:not(:disabled) {
    color: var(--tm-gold);
}

.tm-btn-small {
    padding: var(--tm-space-sm) var(--tm-space-md);
    font-size: 0.8rem;
    background: rgba(197, 165, 90, 0.1);
    color: var(--tm-gold);
    border: 1px solid rgba(197, 165, 90, 0.2);
    border-radius: var(--tm-radius-sm);
}

.tm-arrow {
    font-size: 1.1em;
}

/* Chat Bar */
.tm-chat-bar {
    display: flex;
    gap: var(--tm-space-sm);
    animation: tm-slideUp 0.3s ease-out;
}

.tm-chat-input {
    flex: 1;
    padding: var(--tm-space-md);
    background: var(--tm-bg-input);
    border: 1px solid rgba(197, 165, 90, 0.2);
    border-radius: var(--tm-radius);
    color: var(--tm-cream);
    font-family: var(--tm-font-body);
    font-size: 0.95rem;
    outline: none;
}

.tm-chat-input:focus {
    border-color: var(--tm-gold);
    box-shadow: 0 0 12px rgba(197, 165, 90, 0.15);
}

.tm-chat-input::placeholder {
    color: var(--tm-cream-dark);
}

.tm-chat-send {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tm-burgundy);
    border: 1px solid rgba(197, 165, 90, 0.3);
    border-radius: var(--tm-radius);
    color: var(--tm-gold);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tm-chat-send:hover:not(:disabled) {
    background: var(--tm-burgundy-light);
    border-color: var(--tm-gold);
}

.tm-chat-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

@keyframes tm-slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chat Section (in main content) */
.tm-chat-section {
    background: rgba(197, 165, 90, 0.03);
    border-radius: var(--tm-radius-lg);
    padding: var(--tm-space-md);
    border: 1px solid rgba(197, 165, 90, 0.1);
}

.tm-chat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--tm-cream-dark);
    margin-bottom: var(--tm-space-sm);
}

/* Notes Toggle (collapsed state) */
.tm-notes-toggle {
    display: flex;
    align-items: center;
    gap: var(--tm-space-sm);
    background: transparent;
    border: 1px solid rgba(197, 165, 90, 0.15);
    border-radius: var(--tm-radius-sm);
    padding: var(--tm-space-sm) var(--tm-space-md);
    color: var(--tm-cream-dim);
    font-family: var(--tm-font-body);
    font-size: 0.85rem;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.tm-notes-toggle:hover {
    color: var(--tm-gold);
    border-color: rgba(197, 165, 90, 0.3);
}

.tm-notes-toggle-icon {
    font-size: 1rem;
    color: var(--tm-gold-dim);
    font-weight: 500;
}

.tm-notes-toggle-label {
    font-style: italic;
}

.tm-notes-collapse {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--tm-cream-dark);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 var(--tm-space-xs);
    line-height: 1;
    transition: color 0.2s;
}

.tm-notes-collapse:hover {
    color: var(--tm-gold);
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (min-width: 640px) {
    .tm-main {
        padding: var(--tm-space-xl) var(--tm-space-xxl);
    }

    .tm-message {
        font-size: 1.3rem;
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tm-actions {
        padding-bottom: calc(var(--tm-space-xl) + env(safe-area-inset-bottom));
    }
}

/* =====================================================================
   Transitions (Alpine.js)
   ===================================================================== */
[x-cloak] { display: none !important; }

/* Smooth transitions for Alpine x-show */
[x-transition\:enter] {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
[x-transition\:enter-start] {
    opacity: 0;
    transform: translateY(4px);
}
[x-transition\:leave] {
    transition: opacity 0.2s ease;
}
[x-transition\:leave-end] {
    opacity: 0;
}
