/* ========== Theme Variables ========== */
:root,
[data-theme="dark"] {
    --bg-body: #0F172A;
    --bg-header: #111827;
    --border-header: #1E293B;
    --text-primary: #E2E8F0;
    --text-muted: #64748B;
    --text-chart: #94A3B8;
    --accent-blue: #3B82F6;
    --accent-orange: #F97316;
    --input-bg: #0F172A;
    --input-border: #1E293B;
    --input-focus: #334155;
    --footer-border: #1E293B;
    --footer-text: #95A5A6;
    --footer-link: #60A5FA;
}

[data-theme="light"] {
    --bg-body: #F8FAFC;
    --text-primary: #1E293B;
    --text-muted: #475569;
    --text-chart: #64748B;
    --bg-header: #FFFFFF;
    --border-header: #E2E8F0;
    --input-bg: #FFFFFF;
    --input-border: #CBD5E1;
    --input-focus: #3B82F6;
    --footer-border: #E2E8F0;
    --footer-text: #64748B;
    --footer-link: #1D4ED8;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    background: var(--bg-header);
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-header);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="light"] .header {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1800px;
    margin: 0 auto;
}

/* Theme Toggle */
.theme-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.theme-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 999px;
}

.theme-toggle-track {
    width: 48px;
    height: 26px;
    background: var(--input-border);
    border-radius: 999px;
    position: relative;
    transition: background 0.25s ease;
}

.theme-toggle:hover .theme-toggle-track {
    background: var(--input-focus);
}

.theme-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.25s ease, background 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .theme-toggle-thumb {
    background: #FFFFFF;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .theme-toggle .theme-toggle-track {
    background: var(--accent-blue);
}

[data-theme="light"] .theme-toggle-thumb {
    transform: translateX(22px);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 4px;
    border-radius: 999px;
}

.logo-container {
    max-width: 480px;
}

.logo-container svg {
    max-width: 100%;
    height: auto;
}

/* Main Container */
.container {
    display: grid;
    grid-template-columns: 1fr 500px;
    gap: 4rem;
    padding: 2rem 4rem;
    max-width: 1800px;
    margin: 0 auto;
}

/* Left Panel - Eingaben */
.input-panel {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    height: fit-content;
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

h1 {
    color: var(--accent-blue);
    font-size: 1.25rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.input-section {
    margin-bottom: 2rem;
}

.input-section:last-child {
    border-bottom: none;
}

.input-section h3 {
    color: var(--accent-orange);
    font-size: 1rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

input[type="number"],
select {
    width: 100%;
    padding: 0.625rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--input-focus);
}

/* Right Panel - Canvas */
.canvas-panel {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 600px;
}

.canvas-header {
    display: none;
}

.total-calories {
    display: none;
}

.total-label {
    display: none;
}

.canvas-container {
    width: 100%;
    max-width: 450px;
    margin-top: 2rem;
    position: relative;
}

.canvas-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.canvas-center-value {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--accent-orange);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.canvas-center-label {
    font-size: 1rem;
    color: var(--text-chart);
    font-weight: 500;
}

canvas {
    max-width: 100%;
}

/* Footer */
.site-footer {
    margin-top: 50px;
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--footer-border);
    font-family: 'Inter', sans-serif;
    transition: border-color 0.3s ease;
}

.site-footer p {
    color: var(--footer-text);
    font-size: 12px;
    margin-bottom: 0.5rem;
}

.footer-link {
    color: var(--footer-link);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.footer-link:hover {
    text-decoration: underline;
}

/* Status Message */
#statusMessage {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

#statusMessage .fehler {
    color: #EF4444;
}

/* Responsive - Tablet */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2rem;
    }

    .canvas-panel {
        order: -1; /* Canvas nach oben */
        margin-bottom: 2rem;
        min-height: auto;
    }

    .canvas-container {
        max-width: 400px;
    }

    .input-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .input-panel {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .header {
        padding: 1rem 1.5rem;
    }

    .theme-label {
        display: none;
    }

    .logo-container {
        max-width: 320px;
    }

    .container {
        padding: 1.5rem;
        gap: 2rem;
    }

    h1 {
        font-size: 1.15rem;
        margin-bottom: 1.5rem;
    }

    .input-section h3 {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    label {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
    }

    /* Touch-optimierte Eingabefelder */
    input[type="number"],
    select {
        padding: 0.85rem;
        font-size: 16px; /* Verhindert Auto-Zoom auf iOS */
        min-height: 48px; /* Touch-optimiert */
        border-radius: 8px;
    }

    .canvas-container {
        max-width: 100%;
        margin-top: 1rem;
    }

    .canvas-center-value {
        font-size: 3rem;
    }

    .canvas-center-label {
        font-size: 0.95rem;
    }

    .input-panel {
        max-width: 100%;
    }
}

/* Responsive - Kleine Smartphones */
@media (max-width: 480px) {
    .header {
        padding: 1rem;
    }

    .logo-container {
        max-width: 280px;
    }

    .container {
        padding: 1rem;
        gap: 1.5rem;
    }

    h1 {
        font-size: 1.1rem;
        margin-bottom: 1.25rem;
    }

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

    .input-section h3 {
        font-size: 0.9rem;
        margin-bottom: 0.85rem;
    }

    .form-group {
        margin-bottom: 0.9rem;
    }

    label {
        font-size: 0.85rem;
    }

    input[type="number"],
    select {
        padding: 0.75rem;
        font-size: 16px;
    }

    .canvas-container {
        max-width: 100%;
        margin-top: 0.5rem;
    }

    .canvas-center-value {
        font-size: 2.5rem;
    }

    .canvas-center-label {
        font-size: 0.85rem;
    }

    .canvas-panel {
        min-height: auto;
    }
}

/* Landscape Mode für kleine Geräte */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        padding: 1rem 2rem;
    }

    .canvas-panel {
        order: 0; /* Canvas wieder unten im Landscape */
        margin-bottom: 0;
        margin-top: 1.5rem;
    }

    .canvas-container {
        max-width: 350px;
    }

    .input-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}