/* Honey's Homemade
   Warm, vintage cookbook aesthetic inspired by 1960s family recipes */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
    /* Honey's color palette */
    --cream: #F5F0E8;
    --cream-dark: #EDE6DA;
    --honey: #C4944C;
    --honey-light: #D4A85C;
    --honey-dark: #A67B3D;
    --text-brown: #5C4A3A;
    --text-light: #8B7355;
    --border-tan: #D9CFC0;
    --white: #FDFBF7;
    --rose-pink: #E8D5D0;
    
    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Lora', Georgia, serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--cream);
    color: var(--text-brown);
    line-height: 1.6;
}

/* Main Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--white);
    box-shadow: 0 0 60px rgba(92, 74, 58, 0.08);
}

/* Header - Compact */
.app-header {
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    border-bottom: 1px solid var(--border-tan);
    background: var(--white);
}

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

.logo-emblem {
    width: 50px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-emblem svg {
    width: 100%;
    height: 100%;
}

.title-block {
    text-align: left;
}

.app-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--honey-dark);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.app-subtitle {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-light);
    font-weight: 400;
}

/* Chat Messages Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    background: var(--cream);
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Message Bubbles */
.message {
    max-width: 90%;
    animation: fadeIn 0.3s ease-out;
}

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

.message.user {
    align-self: flex-end;
    margin-left: auto;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: var(--space-md) var(--space-lg);
    border-radius: 4px;
    line-height: 1.7;
}

/* Uploaded image thumbnails */
.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.message-images img {
    max-width: 120px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-tan);
}

.message.user .message-content {
    background: var(--honey);
    color: var(--white);
    border-radius: 20px 20px 4px 20px;
}

.message.assistant .message-content {
    background: var(--white);
    border: 1px solid var(--border-tan);
    color: var(--text-brown);
}

/* Recipe Cards - The Star of the Show */
.recipe-card {
    background: var(--white);
    border: 1px solid var(--border-tan);
    border-radius: 2px;
    margin: var(--space-md) 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(92, 74, 58, 0.06);
}

.recipe-card-header {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px dotted var(--border-tan);
    gap: var(--space-md);
}

.recipe-card-logo {
    width: 45px;
    height: 52px;
    flex-shrink: 0;
}

.recipe-card-logo svg {
    width: 100%;
    height: 100%;
}

.recipe-card-title-block {
    flex: 1;
    border-left: 2px dotted var(--border-tan);
    padding-left: var(--space-md);
}

.recipe-card-brand {
    font-family: var(--font-display);
    font-size: 0.65rem;
    color: var(--text-light);
    text-transform: lowercase;
    letter-spacing: 0.05em;
    margin-bottom: 1px;
}

.recipe-card-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--honey-dark);
    line-height: 1.2;
}

.recipe-card-body {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 0;
}

.recipe-card-ingredients {
    padding: var(--space-sm) var(--space-md);
    border-right: 1px solid var(--border-tan);
    background: var(--cream);
}

.recipe-card-instructions {
    padding: var(--space-sm) var(--space-md);
}

.recipe-section-label {
    font-family: var(--font-display);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-light);
    margin-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-tan);
    padding-bottom: 2px;
}

.recipe-meta {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: var(--space-sm);
}

.ingredients-list {
    list-style: none;
    font-size: 0.8rem;
    line-height: 1.6;
}

.ingredients-list li {
    padding-left: 0;
    position: relative;
}

.ingredients-list li::before {
    content: none;
}

.instructions-text {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-brown);
    text-align: justify;
}

.instructions-text p {
    margin-bottom: var(--space-sm);
    text-indent: 1em;
}

.instructions-text p:first-child {
    text-indent: 0;
}

.recipe-card-footer {
    padding: var(--space-xs) var(--space-md);
    border-top: 1px solid var(--border-tan);
    background: var(--cream);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.recipe-tags {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.recipe-tag {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-style: italic;
    color: var(--text-light);
    background: var(--white);
    padding: 1px 6px;
    border: 1px solid var(--border-tan);
    border-radius: 2px;
}

.recipe-notes {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--rose-pink);
    border-radius: 2px;
    font-style: italic;
    font-size: 0.75rem;
    color: var(--text-brown);
    line-height: 1.4;
}

.recipe-notes::before {
    content: "Note: ";
    font-weight: 600;
    font-style: normal;
}

/* Share Button */
.share-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--honey);
    color: var(--white);
    border: none;
    border-radius: 4px;
    font-family: var(--font-display);
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.share-btn:hover {
    background: var(--honey-dark);
}

.share-btn svg {
    flex-shrink: 0;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-brown);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    z-index: 1000;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Recipe List (search results) */
.recipe-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.recipe-list-item {
    display: flex;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border: 1px solid var(--border-tan);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recipe-list-item:hover {
    background: var(--cream);
    border-color: var(--honey);
}

.recipe-list-item-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--honey-dark);
    flex: 1;
}

.recipe-list-item-author {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
}

/* Input Area */
.input-container {
    padding: var(--space-lg) var(--space-xl);
    background: var(--white);
    border-top: 1px solid var(--border-tan);
}

.input-wrapper {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    min-width: 0; /* Prevent flex overflow */
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-body);
    font-size: 1rem;
    border: 1px solid var(--border-tan);
    max-height: 120px;
    resize: none;
    border-radius: 4px;
    background: var(--cream);
    color: var(--text-brown);
    resize: none;
    min-height: 48px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--honey);
    background: var(--white);
}

.chat-input::placeholder {
    color: var(--text-light);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--honey);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--honey-dark);
}

.btn-primary:disabled {
    background: var(--border-tan);
    cursor: not-allowed;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-tan);
    color: var(--text-light);
    border-radius: 4px;
}

.btn-icon:hover {
    background: var(--cream);
    border-color: var(--honey);
    color: var(--honey);
}

/* Image Upload */
.upload-preview {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.upload-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-tan);
}

.upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--honey);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Loading */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    color: var(--text-light);
    font-style: italic;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--honey);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-light);
}

.welcome-message h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--honey-dark);
    margin-bottom: var(--space-md);
}

.welcome-message p {
    font-size: 0.95rem;
    line-height: 1.7;
    max-width: 400px;
    margin: 0 auto var(--space-lg);
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.welcome-suggestion {
    padding: var(--space-sm) var(--space-md);
    background: var(--white);
    border: 1px solid var(--border-tan);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-brown);
    cursor: pointer;
    transition: all 0.2s ease;
}

.welcome-suggestion:hover {
    background: var(--honey);
    color: var(--white);
    border-color: var(--honey);
}

/* Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--cream);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-tan);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--honey-light);
}

/* Mobile - Compact layout, maximize chat area */
@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    .app-header {
        padding: var(--space-sm) var(--space-md);
        flex-shrink: 0;
    }
    
    .logo-container {
        flex-direction: row;
        gap: var(--space-sm);
    }
    
    .logo-emblem {
        width: 40px;
        height: 40px;
    }
    
    .app-title {
        font-size: 1.2rem;
        margin-top: 0;
    }
    
    .app-subtitle {
        display: none;
    }
    
    .chat-container {
        padding: var(--space-sm);
        flex: 1;
        min-height: 0; /* Critical for flex overflow */
    }
    
    .welcome-card {
        padding: var(--space-md);
    }
    
    .welcome-title {
        font-size: 1.3rem;
    }
    
    .welcome-text {
        font-size: 0.9rem;
        margin-bottom: var(--space-sm);
    }
    
    .quick-actions {
        gap: var(--space-xs);
    }
    
    .quick-action-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.8rem;
    }
    
    .input-container {
        padding: var(--space-sm);
        flex-shrink: 0;
    }
    
    .input-wrapper {
        gap: var(--space-xs);
    }
    
    .chat-input {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
    }
    
    .recipe-card-body {
        grid-template-columns: 1fr;
    }
    
    .recipe-card-ingredients {
        border-right: none;
        border-bottom: 1px solid var(--border-tan);
    }
}

/* Hidden file input */
.hidden-file-input {
    display: none;
}

/* ============================================
   Browse Cookbook Overlay
   Cozy, full-screen cookbook browsing
   ============================================ */

.browse-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #F5F0E8 0%, #EDE6DA 50%, #E8DFD0 100%);
    z-index: 1000;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.browse-overlay.active {
    display: flex;
    opacity: 1;
}

.browse-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: var(--space-md);
    position: relative;
}

.browse-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 40px;
    height: 40px;
    border: none;
    background: var(--white);
    border-radius: 50%;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    transition: all 0.2s ease;
}

.browse-close:hover {
    background: var(--honey);
    color: var(--white);
}

.browse-header {
    text-align: center;
    padding: var(--space-lg) 0 var(--space-md);
}

.browse-counter {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-light);
    letter-spacing: 0.05em;
}

.browse-cards {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    touch-action: pan-y;
}

.browse-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(92, 74, 58, 0.15);
    padding: var(--space-lg);
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
}

.browse-card.active {
    opacity: 1;
    transform: translateX(0);
}

.browse-card.prev {
    transform: translateX(-100%);
}

.browse-card-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--honey-dark);
    text-align: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-tan);
}

.browse-card-section {
    margin-bottom: var(--space-md);
}

.browse-card-section h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--honey);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.browse-card-section ul {
    list-style: none;
    padding: 0;
}

.browse-card-section li {
    padding: var(--space-xs) 0;
    font-size: 0.9rem;
    color: var(--text-brown);
    border-bottom: 1px dotted var(--border-tan);
}

.browse-card-section li:last-child {
    border-bottom: none;
}

.browse-card-section ol {
    padding-left: var(--space-lg);
}

.browse-card-section ol li {
    margin-bottom: var(--space-xs);
}

.browse-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-md) 0;
}

.browse-nav-btn {
    width: 50px;
    height: 50px;
    border: 2px solid var(--honey);
    background: transparent;
    border-radius: 50%;
    color: var(--honey);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.browse-nav-btn:hover:not(:disabled) {
    background: var(--honey);
    color: var(--white);
}

.browse-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.browse-dots {
    display: flex;
    gap: var(--space-xs);
}

.browse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-tan);
    transition: all 0.2s ease;
}

.browse-dot.active {
    background: var(--honey);
    transform: scale(1.2);
}

/* Browse button in welcome area */
.browse-btn {
    background: var(--honey) !important;
    color: var(--white) !important;
    border: none !important;
    font-size: 1rem !important;
    padding: var(--space-sm) var(--space-lg) !important;
}

.browse-btn:hover {
    background: var(--honey-dark) !important;
}

/* Swipe hint animation */
@keyframes swipeHint {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
}

.browse-card.hint {
    animation: swipeHint 1s ease-in-out 2;
}

/* Loading state for browse */
.browse-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    color: var(--text-light);
    font-family: var(--font-display);
    font-style: italic;
}

.browse-loading::before {
    content: "📖";
    font-size: 3rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Mobile adjustments for browse */
@media (max-width: 600px) {
    .browse-container {
        padding: var(--space-sm);
    }
    
    .browse-card {
        padding: var(--space-md);
    }
    
    .browse-card-title {
        font-size: 1.4rem;
    }
    
    .browse-nav-btn {
        width: 44px;
        height: 44px;
    }
}
