:root {
    --background: hsl(42, 100%, 98%);
    --foreground: hsl(25, 30%, 15%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(25, 30%, 15%);
    --primary: hsl(14, 85%, 58%);
    --primary-foreground: hsl(0, 0%, 100%);
    --secondary: hsl(142, 65%, 48%);
    --secondary-foreground: hsl(0, 0%, 100%);
    --muted: hsl(42, 40%, 92%);
    --muted-foreground: hsl(25, 20%, 45%);
    --accent: hsl(38, 92%, 62%);
    --accent-foreground: hsl(25, 30%, 15%);
    --border: hsl(42, 30%, 88%);
    --input: hsl(42, 30%, 88%);
    --ring: hsl(14, 85%, 58%);
    --radius: 0.75rem;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
    --background: hsl(25, 30%, 8%);
    --foreground: hsl(42, 40%, 95%);
    --card: hsl(25, 25%, 12%);
    --card-foreground: hsl(42, 40%, 95%);
    --primary: hsl(14, 85%, 58%);
    --primary-foreground: hsl(0, 0%, 100%);
    --secondary: hsl(142, 65%, 48%);
    --secondary-foreground: hsl(0, 0%, 100%);
    --muted: hsl(25, 20%, 18%);
    --muted-foreground: hsl(42, 30%, 65%);
    --accent: hsl(38, 92%, 62%);
    --accent-foreground: hsl(25, 30%, 8%);
    --border: hsl(25, 20%, 20%);
    --input: hsl(25, 20%, 20%);
    --ring: hsl(14, 85%, 58%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background-color: hsla(0, 0%, 100%, 0.5);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.dark .header {
    background-color: hsla(25, 30%, 8%, 0.8);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 0;
}

.logo-container {
    background: linear-gradient(135deg, hsl(14, 85%, 58%), hsl(38, 92%, 62%));
    padding: 0.5rem;
    border-radius: var(--radius);
}

.chef-hat-icon {
    color: white;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, hsl(14, 85%, 58%), hsl(38, 92%, 62%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--muted);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    margin-left: auto;
}

.dark-mode-toggle:hover {
    background: hsl(var(--muted) / 0.8);
    transform: scale(1.05);
}

.dark-mode-toggle .sun-icon,
.dark-mode-toggle .moon-icon {
    position: absolute;
    color: var(--foreground);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dark-mode-toggle .moon-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

.dark .dark-mode-toggle .sun-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
}

.dark .dark-mode-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

/* Hero Section */
.hero-section {
    max-width: 42rem;
    margin: 0 auto 3rem;
    text-align: center;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--foreground);
    margin-bottom: 1rem;
}

.gradient-text {
    background: linear-gradient(135deg, hsl(14, 85%, 58%), hsl(38, 92%, 62%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--muted-foreground);
}

/* Upload Section */
.upload-section {
    max-width: 42rem;
    margin: 0 auto 2rem;
}

.upload-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 2px 12px hsla(25, 30%, 15%, 0.06);
}

.api-key-section {
    margin-bottom: 1.5rem;
}

.api-key-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.api-key-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--input);
    border-radius: calc(var(--radius) - 0.125rem);
    background: var(--background);
    color: var(--foreground);
    transition: all 0.2s;
    flex: 1;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px hsla(14, 85%, 58%, 0.1);
}

.api-key-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.get-api-key-inline {
    white-space: nowrap;
    padding: 0.55rem 0.9rem;
    background: var(--primary);
    color: var(--primary-foreground);
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.get-api-key-inline:hover {
    background: hsl(14, 85%, 52%);
}


/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-area:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, hsla(14, 85%, 58%, 0.05), hsla(142, 65%, 48%, 0.05));
    transform: scale(1.02);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* Preview Section */
.preview-section {
    position: relative;
}

.preview-image {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px hsla(14, 85%, 58%, 0.08);
}

.reset-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 0.125rem);
    color: var(--foreground);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-button:hover {
    background: var(--muted);
}

/* Scan Button */
.scan-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    margin-top: 1.5rem;
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    border-radius: calc(var(--radius) - 0.125rem);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.scan-button:hover:not(:disabled) {
    background: hsl(14, 85%, 52%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px hsla(14, 85%, 58%, 0.3);
}

.scan-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.scan-button.processing {
    background: #e74c3c !important;
    color: white !important;
    opacity: 1 !important;
    animation: pulse 1.8s infinite;
    cursor: pointer !important;
}

.scan-button.processing:hover {
    background: #c0392b !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Results Section */
.results-section {
    max-width: 56rem;
    margin: 0 auto;
}

.results-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 12px hsla(25, 30%, 15%, 0.06);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.icon-success {
    color: var(--secondary);
}

.icon {
    flex-shrink: 0;
}

/* Ingredients List */
.ingredients-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ingredient-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    opacity: 0;
    transform: translateY(8px);
}

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

.ingredient-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ingredient-name {
    font-weight: 500;
    color: var(--foreground);
}

/* Base confidence bar container */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.confidence-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 6px;
}

.confidence-fill {
    height: 100%;
    border-radius: 6px;
}


/* Recipes Section */
.recipes-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.recipes-list {
    display: grid;
    gap: 1.5rem;
}

.recipe-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 2px 12px hsla(25, 30%, 15%, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.recipe-card:hover {
    box-shadow: 0 8px 32px hsla(25, 30%, 15%, 0.12);
    transform: translateY(-4px);
}

.recipe-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.recipe-icon {
    background: linear-gradient(135deg, hsl(14, 85%, 58%), hsl(38, 92%, 62%));
    padding: 0.5rem;
    border-radius: calc(var(--radius) - 0.125rem);
    color: white;
}

.recipe-title-section {
    flex: 1;
}

.recipe-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.recipe-time {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.recipe-section {
    margin-bottom: 1.5rem;
}

.recipe-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.ingredients-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ingredient-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--muted);
    color: var(--foreground);
    border-radius: 9999px;
    font-size: 0.875rem;
}

.steps-list {
    list-style: none;
    counter-reset: step-counter;
}

.step-item {
    counter-increment: step-counter;
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.step-item::before {
    content: counter(step-counter);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-text {
    flex: 1;
    padding-top: 0.125rem;
}

.show-more-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    margin-top: 0.5rem;
}

.show-more-btn:hover {
    text-decoration: underline;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    margin-top: 4rem;
    padding: 2rem 0;
}

.footer-text {
    text-align: center;
    color: var(--muted-foreground);
}


/* Loading Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
}


/* Responsive Design */
@media (min-width: 768px) {
    .hero-title {
        font-size: 3rem;
    }
}

@media (max-width: 640px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .upload-card {
        padding: 1.5rem;
    }
}

/* API Key Input Section Responsive Adjustments */
@media (max-width: 640px) {
    .api-key-row {
        flex-direction: row !important;
        align-items: center;
    }

    .api-key-input {
        flex: 1 1 auto !important;
        width: auto !important;
    }

    .get-api-key-inline {
        flex-shrink: 0;
    }
}

