/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    /* Harmony Palette (HSL) */
    --primary-grad: linear-gradient(135deg, #FF5E62 0%, #FF9966 100%);
    --primary-hover: linear-gradient(135deg, #E04D51 0%, #E68855 100%);
    --accent-glow: #FF5E62;
    --accent-neon: #00F2FE;
    --accent-green: #00F2FE;
    
    /* Dark glassmorphic color tokens */
    --bg-dark: #0f0c1b;
    --card-bg: rgba(25, 20, 45, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-active: rgba(255, 94, 98, 0.4);
    
    --text-main: #FFFFFF;
    --text-muted: #A3A1B8;
    --text-dark: #121020;
    
    /* Layout */
    --border-radius-sm: 10px;
    --border-radius-md: 18px;
    --border-radius-lg: 26px;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 2rem;
}

/* Background Glow Orbs */
.bg-glow {
    position: fixed;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(140px);
    z-index: -1;
    opacity: 0.2;
    pointer-events: none;
}

.bg-glow-1 {
    background: radial-gradient(circle, #ff5e62 0%, transparent 70%);
    top: -20%;
    left: -20%;
}

.bg-glow-2 {
    background: radial-gradient(circle, #7f00ff 0%, transparent 70%);
    bottom: -20%;
    right: -20%;
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   COMPONENTS: GLASS & CARDS
   ========================================================================== */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.card {
    border-radius: var(--border-radius-md);
    padding: 1.5rem;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.8rem;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==========================================================================
   COMPONENTS: BUTTONS & BADGES
   ========================================================================== */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-grad);
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(255, 94, 98, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 94, 98, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-outline-danger {
    background: transparent;
    color: #FF5E62;
    border: 1px solid rgba(255, 94, 98, 0.3);
}

.btn-outline-danger:hover:not(:disabled) {
    background: rgba(255, 94, 98, 0.1);
    border-color: #FF5E62;
    transform: translateY(-1px);
}

.btn:disabled, .btn-analyze:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Badges */
.badge {
    background: rgba(255, 94, 98, 0.15);
    color: #FF9966;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.live-badge {
    background: rgba(0, 242, 254, 0.12);
    color: var(--accent-neon);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid transparent;
}

.status-online {
    background: rgba(76, 201, 240, 0.1);
    color: #4cc9f0;
    border-color: rgba(76, 201, 240, 0.2);
}

.status-offline {
    background: rgba(255, 94, 98, 0.1);
    color: #FF5E62;
    border-color: rgba(255, 94, 98, 0.2);
}

/* Status Dots */
.status-dot, .pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-online .status-dot { background-color: #4cc9f0; }
.status-offline .status-dot { background-color: #FF5E62; }
.pulse-dot {
    background-color: var(--accent-neon);
    box-shadow: 0 0 8px var(--accent-neon);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 14px var(--accent-neon); }
    100% { transform: scale(0.9); opacity: 0.6; }
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-emoji {
    font-size: 3rem;
    filter: drop-shadow(0 0 15px rgba(255, 94, 98, 0.4));
    animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.logo-text h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.logo-text h1 span {
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p.tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.15rem;
}

/* ==========================================================================
   API KEY PANEL
   ========================================================================== */
.api-panel-card {
    border-radius: var(--border-radius-md);
    padding: 1rem 1.25rem;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.api-toggle-btn {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.api-toggle-btn .toggle-icon {
    font-size: 0.75rem;
    transition: transform 0.3s;
    color: var(--text-muted);
}

.api-content {
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.api-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

.api-content.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.api-help-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.api-input-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.password-wrapper {
    position: relative;
    flex: 1;
    display: flex;
}

.password-wrapper input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
}

.password-wrapper input:focus {
    border-color: rgba(255, 94, 98, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.visibility-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-muted);
    outline: none;
}

.api-status-msg {
    font-size: 0.8rem;
    font-weight: 500;
}
.api-status-msg.success { color: #00F2FE; }
.api-status-msg.error { color: #FF5E62; }

/* Config Panel Grid & Fields */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    width: 100%;
}

.config-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.config-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.config-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
}

.config-input:focus {
    border-color: rgba(255, 94, 98, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.config-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

@media (max-width: 768px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   MAIN GRID LAYOUT
   ========================================================================== */
.app-main {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
}

.column-left, .column-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   WEBCAM VIEWPORT & SCANNER
   ========================================================================== */
.scanner-card {
    position: relative;
}

.webcam-viewport {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: var(--border-radius-sm);
    background: #06040b;
    position: relative;
    overflow: hidden;
    border: 1.5px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

#webcam-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#webcam-container canvas, #webcam-container video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect */
}

.webcam-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.placeholder-icon {
    font-size: 3.5rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.15));
    animation: iconPulse 2s infinite ease-in-out;
}

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

.mini-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #FF5E62;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scanning Overlay Line */
.scan-laser {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-neon), transparent);
    box-shadow: 0 0 12px 3px var(--accent-neon);
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: none;
    animation: scanLaser 3s infinite ease-in-out;
    display: none; /* Diaktifkan saat kamera live */
}

@keyframes scanLaser {
    0% { top: 0%; }
    50% { top: 99%; }
    100% { top: 0%; }
}

.webcam-controls {
    display: flex;
    justify-content: center;
}

.webcam-controls button {
    width: 100%;
    max-width: 250px;
}

/* ==========================================================================
   PREDICTIONS VISUALIZER
   ========================================================================== */
.predictions-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.prediction-placeholder-text {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}

.pred-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pred-label-wrapper {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
}

.pred-name {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pred-val {
    color: var(--accent-neon);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.progress-fill-bar {
    height: 100%;
    border-radius: 50px;
    transition: width 0.15s ease-out;
    background: linear-gradient(90deg, #7f00ff, #ff5e62);
}

/* Highlight high confidence prediction */
.pred-row.active .progress-fill-bar {
    background: linear-gradient(90deg, var(--accent-neon), #00ff87);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.pred-row.active .pred-val {
    color: #00ff87;
    animation: pulseText 1s infinite alternate;
}

@keyframes pulseText {
    0% { text-shadow: 0 0 0px transparent; }
    100% { text-shadow: 0 0 8px rgba(0, 255, 135, 0.6); }
}

/* ==========================================================================
   COLUMN RIGHT: INGREDIENTS LIST
   ========================================================================== */
.ingredients-card {
    flex: 1;
}

.ingredients-container {
    min-height: 160px;
    border-radius: var(--border-radius-sm);
    background: rgba(0, 0, 0, 0.15);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding: 0.5rem;
}

.ingredients-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    gap: 0.5rem;
    color: var(--text-muted);
}

.empty-emoji {
    font-size: 2.2rem;
    margin-bottom: 0.25rem;
    opacity: 0.6;
}

.ingredients-empty h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

.ingredients-empty p {
    font-size: 0.8rem;
    line-height: 1.4;
}

.ingredients-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.85rem;
    width: 100%;
}

.ingredient-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    cursor: default;
    transition: var(--transition-smooth);
}

.ingredient-item:hover {
    background: rgba(255, 94, 98, 0.08);
    border-color: rgba(255, 94, 98, 0.3);
    transform: translateY(-2px);
}

.ing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.ing-name-wrapper {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.ing-emoji {
    font-size: 1.2rem;
}

.ing-name {
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 105px;
}

.ing-nutrition-info {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.45rem;
}

.ing-cal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
}

.ing-cal-label {
    color: var(--text-muted);
}

.ing-cal-value {
    font-weight: 700;
    color: #FF9966;
}

.ing-macros-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ing-macro-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.65rem;
}

.macro-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.6rem;
    text-transform: uppercase;
}

.macro-value {
    color: var(--text-main);
    font-weight: 700;
}

.ing-nutrition-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.45rem;
}

.ing-loading-text {
    animation: pulse 1.5s infinite;
}

.ing-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.ing-delete-btn:hover {
    color: #FF5E62;
    background: rgba(255, 94, 98, 0.15);
    transform: scale(1.1);
}

@keyframes popIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.ingredients-actions {
    display: flex;
    justify-content: flex-end;
}

/* Input Bahan Manual */
.manual-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
}

.manual-input-container input {
    flex: 1;
}

/* Loading State for Ingredient Items */
.ingredient-item.loading {
    border-color: rgba(0, 242, 254, 0.3);
    background: rgba(0, 242, 254, 0.03);
    position: relative;
    overflow: hidden;
}

.ingredient-item.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.08), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(50%); }
}

/* ==========================================================================
   NUTRITION ESTIMATOR CARD
   ========================================================================== */
.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.nutrition-stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.calories-container {
    background: linear-gradient(135deg, rgba(255, 94, 98, 0.08) 0%, rgba(255, 153, 102, 0.08) 100%);
    border: 1px solid rgba(255, 94, 98, 0.15);
    border-radius: 16px;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.5rem;
}

.calories-badge {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.cal-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 0.25rem;
}

.cal-value {
    font-size: 2rem;
    font-weight: 800;
    color: #FF9966;
    line-height: 1;
    letter-spacing: -0.03em;
    text-shadow: 0 0 15px rgba(255, 153, 102, 0.35);
}

.cal-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.calories-bar-wrapper {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    overflow: hidden;
}

.calories-bar {
    height: 100%;
    background: var(--primary-grad);
    border-radius: 50px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 0 8px rgba(255, 94, 98, 0.5);
}

.nutrition-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* ==========================================================================
   ACTION BUTTON SECTION
   ========================================================================== */
.action-section {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.btn-analyze {
    width: 100%;
    max-width: 500px;
    padding: 1.1rem 2rem;
    border-radius: var(--border-radius-md);
    background: var(--primary-grad);
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    border: none;
    text-align: center;
    box-shadow: 0 8px 30px rgba(255, 94, 98, 0.35);
    transition: var(--transition-smooth);
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.btn-analyze::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transform: skewX(-25deg);
    transition: none;
}

.btn-analyze:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(255, 94, 98, 0.5);
}

.btn-analyze:hover:not(:disabled)::before {
    left: 150%;
    transition: all 0.8s ease-in-out;
}

.btn-analyze:active:not(:disabled) {
    transform: translateY(-1px) scale(1.0);
}

/* ==========================================================================
   LOADING ANIMATION (PREVENT BLOCK)
   ========================================================================== */
.recipe-loading {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
    animation: fadeIn 0.4s ease;
}

.loading-content {
    width: 100%;
    max-width: 600px;
    border-radius: var(--border-radius-md);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

/* Bubbling Pot Chef Animation */
.chef-animation {
    width: 100px;
    height: 100px;
    position: relative;
    margin-bottom: 0.5rem;
}

.pot {
    width: 70px;
    height: 50px;
    background: #5d537d;
    border: 3px solid #3c3553;
    border-radius: 4px 4px 20px 20px;
    position: absolute;
    bottom: 10px;
    left: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.pot::before {
    content: '';
    width: 76px;
    height: 6px;
    background: #3c3553;
    border-radius: 3px;
    position: absolute;
    top: -6px;
    left: -6px;
}

.spoon {
    width: 4px;
    height: 50px;
    background: #d4a373;
    position: absolute;
    top: 15px;
    left: 55px;
    border-radius: 2px;
    transform-origin: bottom center;
    animation: stir 1.8s infinite ease-in-out;
}

.spoon::before {
    content: '';
    width: 10px;
    height: 14px;
    background: #d4a373;
    border-radius: 50% 50% 50% 50%;
    position: absolute;
    top: -10px;
    left: -3px;
}

@keyframes stir {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(15deg); }
}

.bubble {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FF9966;
    position: absolute;
    opacity: 0;
}

.bubble-1 { left: 10px; bottom: 45px; animation: floatBubble 1.2s infinite 0.2s ease-in; }
.bubble-2 { left: 25px; bottom: 45px; animation: floatBubble 1.5s infinite 0.6s ease-in; }
.bubble-3 { left: 40px; bottom: 45px; animation: floatBubble 1s infinite 0.1s ease-in; }
.bubble-4 { left: 52px; bottom: 45px; animation: floatBubble 1.3s infinite 0.8s ease-in; }

@keyframes floatBubble {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    50% { opacity: 0.8; }
    100% { transform: translateY(-30px) scale(1.1); opacity: 0; }
}

.loading-quote {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    min-height: 1.4rem;
}

.progress-bar-loading {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-grad);
    border-radius: 50px;
    animation: fillProgress 12s infinite linear;
}

@keyframes fillProgress {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* ==========================================================================
   RESULT CARD SECTION
   ========================================================================== */
.recipe-result-container {
    animation: slideUp 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes slideUp {
    0% { transform: translateY(30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.result-card {
    border-radius: var(--border-radius-lg);
    padding: 2.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    border-color: rgba(255, 94, 98, 0.25);
    box-shadow: 0 10px 40px rgba(255, 94, 98, 0.1);
}

.result-header {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 1.2rem;
}

.recipe-badge {
    color: #FF9966;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#recipe-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #FFFFFF, #FFE0D3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.recipe-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 2px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    position: relative;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: #FF9966;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-grad);
    border-radius: 50px;
    box-shadow: 0 0 10px rgba(255, 94, 98, 0.5);
}

/* Tab Contents */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Tab 1: Ingredients Layout */
.recipe-ingredients-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.ingredient-box {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 1.25rem;
}

.ingredient-box h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 0.5rem;
}

.ingredient-box ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ingredient-box li {
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ingredient-box li::before {
    content: '🔹';
    font-size: 0.75rem;
}

/* Tab 2: Steps Layout */
.steps-wrapper {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    padding: 1.25rem;
}

.steps-wrapper h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.steps-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    counter-reset: steps-counter;
}

.steps-list li {
    position: relative;
    padding-left: 3rem;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-main);
}

.steps-list li::before {
    counter-increment: steps-counter;
    content: counter(steps-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    background: var(--primary-grad);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 3px 8px rgba(255, 94, 98, 0.25);
}

/* Tab 3: Tips & Nutrition Layout */
.tips-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
}

.tips-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tips-box h3 {
    font-size: 1.05rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 0.5rem;
}

.tips-box p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-main);
}

/* Result Actions */
.result-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 1.2rem;
}

.result-actions button {
    flex: 1;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer {
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-footer p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.app-footer p.credits {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Utility Hidden */
.hidden {
    display: none !important;
}

/* ==========================================================================
   COOKING PREFERENCES PANEL STYLES
   ========================================================================== */
.preferences-card {
    background: rgba(25, 20, 45, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    margin-bottom: 0.5rem;
}

.preferences-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.pref-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.pref-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.pref-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.pref-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 50px;
    padding: 0.5rem 1.1rem;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    outline: none;
}

.pref-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    transform: translateY(-1.5px);
}

/* Active status with curated harmonious color glows */
#pref-dish-type .pref-chip.active {
    background: var(--primary-grad);
    border-color: transparent;
    color: var(--text-main);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(255, 94, 98, 0.4);
}

#pref-spiciness .pref-chip.active {
    background: linear-gradient(135deg, #FF9966 0%, #FF5E62 100%);
    border-color: transparent;
    color: var(--text-main);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(255, 153, 102, 0.4);
}

#pref-culinary-style .pref-chip.active {
    background: linear-gradient(135deg, #00F2FE 0%, #4FACFE 100%);
    border-color: transparent;
    color: var(--text-main);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

/* ==========================================================================
   RESPONSIVENESS (MOBILE FRIENDLY)
   ========================================================================== */
@media (max-width: 900px) {
    .app-main {
        grid-template-columns: 1fr;
    }
    
    .logo-emoji {
        font-size: 2.5rem;
    }
    
    .logo-text h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .header-status {
        align-self: flex-end;
    }
    
    .api-input-group {
        flex-direction: column;
    }
    
    .api-input-group button {
        width: 100%;
    }
    
    .recipe-ingredients-layout, .tips-layout {
        grid-template-columns: 1fr;
    }
    
    .tab-nav {
        flex-wrap: wrap;
        gap: 2px;
    }
    
    .tab-btn {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
        flex: 1;
        text-align: center;
    }
    
    .result-card {
        padding: 1.25rem;
        gap: 1.25rem;
    }
    
    #recipe-title {
        font-size: 1.5rem;
    }
    
    .result-actions {
        flex-direction: column;
    }
}
