/* --- Bestehende CSS Basis --- */
:root {
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --bg-input: #2a2a2a;
    --primary: #c0a062;
    --primary-dark: #a3854d;
    --accent: #800020;
    --text-main: #f0f0f0;
    --text-muted: #a0a0a0;
    --border: #333;
    --success: #4caf50;
    --danger: #ef5350;
    --nav-height: 65px;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Inter', sans-serif; background-color: var(--bg-dark); color: var(--text-main); padding-bottom: calc(var(--nav-height) + 20px); }
h1, h2, h3 { font-family: 'Playfair Display', serif; font-weight: 600; margin: 0 0 1rem 0; }
a { text-decoration: none; color: inherit; }

/* Auth */
.auth-layer { position: fixed; inset: 0; z-index: 1000; background: url('https://images.unsplash.com/photo-1516594915697-87eb3b1c14ea?q=80&w=1000&auto=format&fit=crop') center/cover; display: flex; align-items: center; justify-content: center; }
.auth-layer::before { content:''; position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); }
.auth-card { position: relative; background: rgba(30,30,30,0.8); border: 1px solid rgba(255,255,255,0.1); padding: 2.5rem; border-radius: 24px; text-align: center; width: 90%; max-width: 350px; backdrop-filter: blur(20px); box-shadow: var(--shadow); }
.logo-circle { width: 60px; height: 60px; background: var(--primary); color: #000; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto 1rem; }
.auth-card input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: rgba(0,0,0,0.3); color: white; margin: 1rem 0; text-align: center; font-size: 1.1rem; }
.error-toast { color: var(--danger); margin-top: 10px; font-size: 0.9rem; display: none; }

/* Header */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: rgba(18,18,18,0.95); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); }
.brand { font-family: 'Playfair Display', serif; font-size: 1.4rem; color: var(--primary); display: flex; gap: 10px; align-items: center; }
.icon-btn { background: none; border: none; color: var(--text-main); font-size: 1.2rem; cursor: pointer; }
.desktop-nav { display: none; gap: 20px; }
.nav-link { color: var(--text-muted); font-weight: 500; font-size: 0.95rem; padding: 8px 12px; border-radius: 8px; transition: 0.2s; cursor: pointer;}
.nav-link:hover { color: var(--text-main); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--primary); background: rgba(192, 160, 98, 0.1); }

/* Content */
.content-area { padding: 20px; max-width: 1200px; margin: 0 auto; }
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 25px; }
.stat-item { background: var(--bg-card); padding: 15px; border-radius: var(--radius); text-align: center; border: 1px solid var(--border); }
.stat-val { font-size: 1.6rem; font-weight: 700; color: var(--primary); display: block; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.chart-card { background: var(--bg-card); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); }
.chart-wrapper { position: relative; height: 300px; width: 100%; }

/* Filter & Search */
.sticky-search { position: sticky; top: 75px; z-index: 90; background: var(--bg-dark); padding-bottom: 15px; }
.search-bar { display: flex; align-items: center; background: var(--bg-input); padding: 0 15px; border-radius: 50px; border: 1px solid var(--border); }
.search-bar input { flex: 1; background: none; border: none; padding: 12px; color: white; outline: none; }
.filter-chips { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.chip { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-muted); padding: 6px 16px; border-radius: 20px; white-space: nowrap; font-size: 0.9rem; cursor: pointer; transition: 0.2s; }
.chip.active { background: var(--primary); color: #000; border-color: var(--primary); }

/* --- COLLECTION FEATURES (NEU) --- */

.wine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; } /* Etwas breiter für mehr Details */

.wine-card { background: var(--bg-card); border-radius: var(--radius); overflow: hidden; position: relative; border: 1px solid var(--border); transition: transform 0.2s; cursor: pointer; }
.wine-card:active { transform: scale(0.98); }

.wine-img-wrapper { height: 180px; position: relative; background: #252525; }
.wine-img-wrapper img { width: 100%; height: 100%; object-fit: cover; }

.wine-rating-badge { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.8); color: var(--primary); padding: 4px 8px; border-radius: 6px; font-weight: bold; font-size: 0.85rem; backdrop-filter: blur(4px); border: 1px solid var(--primary); }

/* ROI Badge (Gewinn/Verlust) */
.roi-badge { position: absolute; bottom: 10px; right: 10px; padding: 4px 8px; border-radius: 6px; font-weight: bold; font-size: 0.8rem; backdrop-filter: blur(4px); }
.roi-pos { background: rgba(76, 175, 80, 0.9); color: white; }
.roi-neg { background: rgba(239, 83, 80, 0.9); color: white; }

.wine-info { padding: 15px; }
.wine-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.wine-winery { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.wine-location { font-size: 0.75rem; color: var(--primary); background: rgba(192, 160, 98, 0.1); padding: 2px 6px; border-radius: 4px; }

.wine-name { font-family: 'Playfair Display', serif; font-size: 1.2rem; margin: 0 0 10px 0; line-height: 1.2; }

/* Trinkreife Balken */
.maturity-bar-container { width: 100%; height: 4px; background: #333; border-radius: 2px; margin-bottom: 5px; overflow: hidden; }
.maturity-bar { height: 100%; background: var(--text-muted); border-radius: 2px; }
.mat-young { background: #64b5f6; } /* Blau: Zu jung */
.mat-peak { background: #4caf50; } /* Grün: Perfekt */
.mat-drink { background: #ffb74d; } /* Orange: Trinken */
.mat-old { background: #ef5350; } /* Rot: Überfällig */
.maturity-label { font-size: 0.75rem; margin-bottom: 10px; font-weight: 500; }
.maturity-label.mat-peak { color: #4caf50; }
.maturity-label.mat-old { color: #ef5350; }

.wine-meta { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.05); }
.stock-badge { color: var(--text-main); font-weight: 600; }
.stock-badge.low { color: var(--danger); }

/* --- Nav & Modal --- */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height); background: rgba(18,18,18,0.95); border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: center; backdrop-filter: blur(10px); z-index: 500; padding-bottom: env(safe-area-inset-bottom); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-muted); font-size: 0.7rem; width: 60px; }
.nav-item i { font-size: 1.4rem; transition: 0.2s; }
.nav-item.active { color: var(--primary); }
.nav-add-btn { width: 50px; height: 50px; background: var(--primary); color: #000; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; transform: translateY(-20px); box-shadow: 0 0 15px rgba(192, 160, 98, 0.4); }
.fab-add { position: fixed; bottom: 90px; right: 20px; width: 56px; height: 56px; background: var(--primary); color: #000; border-radius: 50%; border: none; font-size: 1.5rem; box-shadow: var(--shadow); z-index: 90; cursor: pointer; display: grid; place-items: center; }

.modal-layer { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 2000; display: none; align-items: flex-end; justify-content: center; backdrop-filter: blur(5px); }
.modal-layer.active { display: flex; animation: slideUp 0.3s forwards; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-card { background: var(--bg-card); width: 100%; max-width: 600px; border-radius: 24px 24px 0 0; padding: 25px; max-height: 90vh; overflow-y: auto; border-top: 1px solid rgba(255,255,255,0.1); }
.full-height { height: 90vh; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 2rem; padding: 0; line-height: 0.8; cursor: pointer; }

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group-row.small-gap { grid-template-columns: 1fr auto; }
label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.checkbox-align { display: flex; align-items: flex-end; padding-bottom: 10px; }
.checkbox-wrapper { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-wrapper input { width: auto; margin: 0; }
input, select, textarea { width: 100%; background: var(--bg-input); border: 1px solid var(--border); padding: 12px; border-radius: 12px; color: white; font-family: inherit; font-size: 1rem; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
.btn-primary { background: var(--primary); color: #000; border: none; padding: 14px; border-radius: 12px; font-weight: 600; font-size: 1rem; cursor: pointer; width: 100%; }
.btn-primary:active { transform: scale(0.98); background: var(--primary-dark); }
.file-upload-styled { border: 2px dashed var(--border); border-radius: 12px; padding: 20px; text-align: center; position: relative; cursor: pointer; }
.file-upload-styled input { opacity: 0; position: absolute; inset: 0; cursor: pointer; }

/* Toast */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(50px); background: #333; color: white; padding: 12px 24px; border-radius: 50px; opacity: 0; transition: 0.3s; pointer-events: none; z-index: 3000; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Desktop Tweaks */
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .content-area { padding-left: 20px; padding-right: 20px; }
    .app-header { padding: 20px 40px; }
    .desktop-nav { display: flex; }
    .modal-layer { align-items: center; }
    .modal-card { border-radius: 24px; max-height: 85vh; }
    .wine-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .fab-add { display: none; }
    .sticky-search { top: 85px; }
    body { padding-bottom: 0; padding-left: 0; }
    .app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
    .content-area { flex: 1; }
}