/* --- File: ./static/css/style.css --- */
:root {
    --bg-color: #f5f6fa;
    --text-color: #2f3640;
    --card-bg: #ffffff;
    --primary: #0097e6;
    --primary-hover: #00a8ff;
    --nav-bg: #2f3640;
    --nav-text: #f5f6fa;
    --border: #dcdde1;
    --danger: #e84118;
    --success: #4cd137;
    --info: #00a8ff;
    --input-bg: #ffffff;
    
    --allergen-color: #8E44AD;
    --sugar-color: #D35400;
}

html.dark-mode {
    --bg-color: #151b20;
    --text-color: #f5f6fa;
    --card-bg: #22282e;
    --primary: #00a8ff;
    --primary-hover: #0097e6;
    --nav-bg: #0a0c0e;
    --nav-text: #f5f6fa;
    --border: #353f48;
    --danger: #c23616;
    --success: #44bd32;
    --info: #0097e6;
    --input-bg: #1e252b;
    color-scheme: dark; 
    
    --allergen-color: #FBE870;
    --sugar-color: #698CAF;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    max-width: 100vw;
    overflow-x: hidden;
}

nav {
    background-color: var(--nav-bg);
    color: var(--nav-text);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .nav-links a, nav .nav-links button {
    color: var(--nav-text);
    text-decoration: none;
    margin-left: 1.5rem;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    nav { padding: 0.5rem 1rem; }
    nav .logo { font-size: 1.1rem; }
    nav .nav-links { display: flex; gap: 0.8rem; margin: 0; align-items: center; }
    nav .nav-links a { margin-left: 0; font-size: 0; padding: 0.5rem 0.2rem; }
    nav .nav-links a i { font-size: 1.2rem; }
    nav .nav-links button { margin-left: 0; font-size: 0; padding: 0.5rem 0.2rem; }
    nav .nav-links button i { font-size: 1.2rem; }
}

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

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
    min-width: 0;
    overflow-wrap: break-word;
}

.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 1.5rem;
}
.grid-view .grid-card { display: flex; flex-direction: column; }
.grid-view .grid-card img, .grid-view .placeholder-img { width: 100%; height: 200px; object-fit: cover; border-radius: 4px; margin-bottom: 1rem; }

.list-view { display: flex; flex-direction: column; gap: 0.5rem; }
.list-view .grid-card { display: flex; flex-direction: row; align-items: center; padding: 0.5rem 1rem; }
.list-view .grid-card img, .list-view .placeholder-img { width: 50px; height: 50px; min-width: 50px; object-fit: cover; border-radius: 4px; margin-bottom: 0; margin-right: 1.5rem; }
.list-view .card-content { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: space-between; }
.list-view .card-actions { margin-top: 0; padding-top: 0; border-top: none; display: flex; gap: 0.5rem; }

.compact-view { display: flex; flex-direction: column; gap: 0; }
.compact-view .grid-card { flex-direction: row; padding: 0.4rem 0.8rem; margin: 0; border: none; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; background: transparent; align-items: center;}
.compact-view .grid-card:last-child { border-bottom: none; }
.compact-view .grid-card img, .compact-view .placeholder-img { display: none !important; }
.compact-view .card-content { flex: 1; display: flex; flex-direction: row; justify-content: space-between; align-items: center; padding: 0; min-width: 0; }
.compact-view .card-content > div:first-child { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; min-width: 0;}
.compact-view .card-content > div:first-child strong { font-size: 1rem; }
.compact-view .card-content > div:first-child span { font-size: 0.85rem; opacity: 0.8; margin: 0; }
.compact-view .card-actions { margin: 0; padding: 0; border: none; display: flex; gap: 0.3rem; flex-shrink: 0; }
.compact-view .card-actions .btn { height: 26px; width: 28px; padding: 0; display: inline-flex; justify-content: center; align-items: center; font-size: 0.8rem;}
@media (max-width: 768px) {
    .compact-view .card-content > div:first-child { flex-direction: column; align-items: flex-start; gap: 0; }
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; }

input[type="text"], input[type="number"], input[type="password"],
input[type="date"], input[type="time"], select {
    width: 100%; height: 40px; padding: 0 0.5rem; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 4px;
    background-color: var(--input-bg) !important; color: var(--text-color) !important;
    font-family: inherit; max-width: 100%;
}

select { text-overflow: ellipsis; }

textarea {
    width: 100%; padding: 0.5rem; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 4px;
    background-color: var(--input-bg) !important; color: var(--text-color) !important;
    font-family: inherit; resize: vertical; max-width: 100%;
}

input[type="checkbox"] { width: auto; height: auto; display: inline-block; margin-right: 0.5rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 168, 255, 0.2); }

/* FIX: Saubere Button Themes und Hower States ohne Farb-Ueberschreibung */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; height: 40px; box-sizing: border-box; background-color: var(--primary); color: #fff; padding: 0 1rem; text-decoration: none; border: none; border-radius: 4px; cursor: pointer; font-size: 1rem; transition: filter 0.2s; }
.btn:hover { filter: brightness(1.15); }
.btn-danger { background-color: var(--danger); }
.btn-success { background-color: var(--success); }
.btn-secondary { background-color: var(--nav-bg); color: var(--nav-text); }
.btn-info { background-color: var(--info); }
.btn-purple { background-color: #9b59b6; color: #fff; }
.btn-small { height: 30px; padding: 0 0.6rem; font-size: 0.85rem; }

/* FIX: Einheitliche Formular-Strukturen und Groessen */
.form-row { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1rem; align-items: flex-end; max-width: 100%; }
.form-row > * { flex: 1 1 140px; min-width: 0; max-width: 100%; }
.form-row > .full-width { flex: 1 1 100%; }

.col-time { flex: 0 0 110px !important; max-width: 110px !important; }
.col-btn { flex: 0 0 auto !important; min-width: 150px !important; }
.row-right { justify-content: flex-end; margin-top: 1rem; margin-bottom: 0; }

.flex-split { display: flex; gap: 2rem; flex-wrap: wrap; max-width: 100%; }
.flex-split > * { min-width: 0; max-width: 100%; }

.flash-message { padding: 1rem; margin-bottom: 1rem; border-radius: 4px; color: white; font-weight: bold; }
.flash-message.success { background-color: var(--success); }
.flash-message.error { background-color: var(--danger); }
.flash-message.info { background-color: var(--info); }

.search-bar { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.search-bar input { flex: 1; height: 44px; padding: 0 1rem; border: 1px solid var(--border); border-radius: 4px; background: var(--input-bg); color: var(--text-color); }
.search-bar button { height: 44px; }

.nutrition-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin-bottom: 1.5rem; }
.nutrition-table th, .nutrition-table td { padding: 0.5rem 0; border-bottom: 1px solid var(--border); text-align: left; }
.nutrition-table th { font-weight: normal; }
.nutrition-table td { text-align: right; font-weight: bold; }
.nutrition-table .sub-item th { padding-left: 1.5rem; font-size: 0.85rem; opacity: 0.8; }
.nutrition-table .sub-item td { font-size: 0.85rem; font-weight: normal; }

.slim-list { list-style: none; padding: 0; margin: 0 0 1.5rem 0; }
.slim-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); gap: 0.5rem; }
.slim-list li:last-child { border-bottom: none; }

.slim-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; width: 100%; }
.slim-form > * { min-width: 0; }
.slim-form input { height: 40px; box-sizing: border-box; margin: 0; padding: 0 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-color); color: var(--text-color); }

.custom-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2rem; margin-top: 1.5rem; font-size: 0.9rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-color { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }

.action-bar { margin-top: 2.5rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-content { background: var(--card-bg); padding: 2rem; border-radius: 8px; width: 90%; max-width: 500px; border: 1px solid var(--border); position: relative; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; color: var(--text-color); cursor: pointer; line-height: 1; }

.diary-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 1.5rem; align-items: start; }
@media (max-width: 768px) { .diary-grid { grid-template-columns: 1fr; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
.stat-value { font-size: 2.2rem; font-weight: bold; margin: 0.5rem 0; }
.stat-label { font-size: 0.85rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 1px; }
.stat-unit { font-size: 1rem; opacity: 0.7; font-weight: normal; }

.select2-container--default .select2-selection--single { background-color: var(--input-bg) !important; border: 1px solid var(--border) !important; border-radius: 4px !important; height: 40px !important; display: flex !important; align-items: center !important; overflow: hidden !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--text-color) !important; line-height: normal !important; padding-left: 0.5rem !important; flex: 1; min-width: 0; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 38px !important; }
.select2-dropdown { background-color: var(--input-bg) !important; border: 1px solid var(--primary) !important; color: var(--text-color) !important; }
.select2-search--dropdown .select2-search__field { background-color: var(--bg-color) !important; color: var(--text-color) !important; border: 1px solid var(--border) !important; border-radius: 4px !important; outline: none !important; }
.select2-search--dropdown .select2-search__field:focus { border: 1px solid var(--primary) !important; }
.select2-container--default .select2-results__option { color: var(--text-color) !important; background-color: var(--input-bg) !important; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background-color: var(--primary) !important; color: #ffffff !important; }
.select2-container--default .select2-results__option[aria-selected=true] { background-color: var(--bg-color) !important; color: var(--text-color) !important; }

.allergen { font-weight: bold !important; color: var(--allergen-color) !important; }
.sugar { font-weight: bold !important; color: var(--sugar-color) !important; }

/* Diary Tabs */
.tab-nav { display: flex; width: 100%; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab-nav button { flex: 1; display: flex; justify-content: center; align-items: center; gap: 0.5rem; background: none; border: none; padding: 0.8rem 0; cursor: pointer; font-size: 1rem; color: var(--text-color); opacity: 0.6; border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: bold; }
.tab-nav button.active { opacity: 1; border-bottom: 2px solid var(--primary); color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
@media (max-width: 768px) {
    .tab-nav button span { display: none; }
    .tab-nav button i { font-size: 1.5rem; margin: 0; }
}

.checkbox-group { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.checkbox-group label { display: flex; align-items: center; font-weight: normal; margin: 0; cursor: pointer; }
.checkbox-group input { margin-right: 0.4rem; }

/* EASTER EGG ANIMATIONS */
@keyframes spinPage {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.5); }
    100% { transform: rotate(360deg) scale(1); }
}
.spin-animation { animation: spinPage 2s ease-in-out; overflow: hidden; }

.fanfare-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.8); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    animation: fadeOut 4s forwards; pointer-events: none;
}
.fanfare-text {
    color: #FFD700; font-size: 4rem; text-align: center;
    text-shadow: 0 0 20px #FF8C00;
    animation: zoomIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes fadeOut { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes zoomIn { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
