/* =======================================
   BASIS & VARIABLEN
   ======================================= */
:root {
    --bg-color: #f4f4f9;
    --primary-color: #2c3e50; /* Edles Dunkelblau/Grau */
    --accent-color: #8e44ad; /* Wein-Akzent */
    --text-main: #333;
    --card-bg: #fff;
    --danger: #e74c3c;
    --success: #27ae60;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}

body { 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    padding-bottom: 80px; /* Platz für die Bottom-Nav */
}

header { 
    background-color: var(--primary-color); 
    color: white; 
    text-align: center; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
}

header h1 { 
    font-size: 1.5rem; 
    font-weight: 600; 
}

main { 
    padding: 1rem; 
    max-width: 800px; 
    margin: 0 auto; 
}

/* =======================================
   ANSICHTEN (ROUTING)
   ======================================= */
.view { 
    display: none; 
    animation: fadeIn 0.3s ease; 
}

.view.active { 
    display: block; 
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(5px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* =======================================
   TYPOGRAFIE & INFOS
   ======================================= */
h2 { 
    margin-bottom: 1.2rem; 
    color: var(--primary-color); 
    font-size: 1.4rem; 
    border-bottom: 2px solid #ddd; 
    padding-bottom: 0.5rem; 
}

.total-subtitle { 
    font-size: 1.1rem; 
    color: var(--accent-color); 
    font-weight: 600; 
    margin-bottom: 1.2rem; 
    margin-top: 0.2rem; 
}

.section-subtitle { 
    margin: 1.5rem 0 1rem 0; 
    font-size: 1.1rem; 
    color: var(--primary-color); 
}

.status-box, .info-box { 
    background: #e8f4fd; 
    border-left: 4px solid #3498db; 
    padding: 1rem; 
    border-radius: 4px; 
    margin-bottom: 1.5rem; 
    font-size: 0.95rem; 
    line-height: 1.4; 
}

.warning-text { 
    color: var(--danger); 
    font-size: 0.85rem; 
    min-height: 20px; 
    font-weight: bold; 
}

/* =======================================
   FORMULARE & SUCHE
   ======================================= */
.form-group { margin-bottom: 1rem; }
.form-row { display: flex; gap: 10px; }
.form-row .half { flex: 1; }
.form-row .third { flex: 1; }

label { 
    display: block; 
    margin-bottom: 0.4rem; 
    font-weight: 500; 
    font-size: 0.9rem; 
    color: #555; 
}

input, select { 
    width: 100%; 
    padding: 0.8rem; 
    border: 1px solid #ccc; 
    border-radius: 8px; 
    font-size: 1rem; 
    background: #fff; 
}

input:focus, select:focus { 
    outline: none; 
    border-color: var(--accent-color); 
    box-shadow: 0 0 0 2px rgba(142, 68, 173, 0.2); 
}

#search-input { 
    margin-bottom: 1rem; 
    border-radius: 20px; 
    padding: 0.8rem 1.2rem; 
    border: 1px solid #bbb; 
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); 
}

/* =======================================
   FILTER & SORTIERUNG
   ======================================= */
.inventory-controls { 
    display: flex; 
    flex-direction: column; 
    gap: 0.8rem; 
    margin-bottom: 1rem; 
}

.filter-chips { 
    display: flex; 
    gap: 0.8rem; 
    overflow-x: auto; 
    padding-bottom: 0.5rem; 
    scrollbar-width: none; 
}
.filter-chips::-webkit-scrollbar { display: none; }

.filter-chip { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 48px; 
    height: 48px; 
    padding: 0; 
    border-radius: 50%; 
    border: 2px solid #ddd; 
    background: #fff; 
    cursor: pointer; 
    transition: all 0.2s; 
    flex-shrink: 0; 
}

.filter-icon { 
    width: 22px; 
    height: 22px; 
    fill: #777; 
    transition: all 0.2s; 
}

.colored-icon { fill: var(--icon-color); }
.white-wine-icon { stroke: #d4c07c; stroke-width: 1px; }

.filter-chip.active { 
    background: var(--primary-color); 
    border-color: var(--primary-color); 
}
.filter-chip.active .filter-icon { 
    fill: white !important; 
    stroke: transparent !important; 
}

.sort-select { 
    padding: 0.6rem 1rem; 
    border-radius: 8px; 
    border: 1px solid #ccc; 
    font-size: 0.9rem; 
    background: #fff; 
    color: #555; 
    width: 100%; 
    align-self: flex-start; 
    cursor: pointer; 
    font-weight: 500;
}

/* =======================================
   KAMERA & BILDER
   ======================================= */
.photo-capture-area { 
    margin-bottom: 1.5rem; 
    text-align: center; 
    background: #fff; 
    padding: 1rem; 
    border-radius: 8px; 
    border: 1px dashed #ccc; 
}

.preview-area { 
    text-align: center; 
    margin-bottom: 1.5rem; 
}
.preview-area img { 
    max-height: 200px; 
    border-radius: 8px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
}

/* =======================================
   BUTTONS
   ======================================= */
button { 
    padding: 1rem; 
    border: none; 
    border-radius: 8px; 
    font-size: 1rem; 
    cursor: pointer; 
    width: 100%; 
    font-weight: 600; 
    transition: all 0.2s; 
}

.primary-btn { background-color: var(--accent-color); color: white; margin-top: 1rem; box-shadow: 0 4px 6px rgba(142, 68, 173, 0.2); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { background-color: #95a5a6; cursor: not-allowed; box-shadow: none; }

.secondary-btn { background-color: #e0e0e0; color: #333; margin-top: 0.5rem; }
#trigger-camera-btn { background-color: var(--primary-color); color: white; margin-top: 0; }

.text-btn { background: none; color: var(--danger); font-size: 0.9rem; padding: 0.5rem; width: auto; margin-top: 0.5rem; }

.action-icon-btn { padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.85rem; width: auto; font-weight: bold; }
.drink-btn { background-color: var(--accent-color); color: white; }
.delete-btn { background-color: var(--danger); color: white; }

/* =======================================
   WEIN-KARTEN (LISTEN-ANSICHT)
   ======================================= */
.wine-grid { display: flex; flex-direction: column; gap: 1.2rem; }

.wine-card { 
    background: var(--card-bg); 
    border-radius: 12px; 
    overflow: hidden; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    display: flex; 
    border: 1px solid #eee; 
}

.wine-image { 
    width: 120px; 
    background-color: #111; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    position: relative; 
    cursor: pointer;    
}
.wine-image img { width: 100%; height: 100%; object-fit: cover; }

.magnifier-overlay {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.8rem;
    width: 26px;
    height: 26px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    pointer-events: none; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.wine-details { 
    padding: 1.2rem; 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
}

.wine-title { 
    font-size: 1.4rem; 
    font-weight: 700; 
    color: var(--primary-color); 
    margin-bottom: 0.4rem; 
    letter-spacing: -0.5px; 
    line-height: 1.2; 
}

.wine-quantity-visual { margin: 0.5rem 0 1rem 0; font-size: 1.2rem; letter-spacing: 2px; }

.wine-tag { 
    display: inline-block; 
    background: #eee; 
    padding: 0.2rem 0.5rem; 
    border-radius: 4px; 
    font-size: 0.85rem; 
    color: #555; 
    margin-bottom: 0.5rem; 
    margin-right: 0.3rem;
}

.type-Rot { background-color: #722F37; color: white; border: none; }
.type-Weiss { background-color: #F8E5A1; color: #333; border: none; }
.type-Rose { background-color: #FFC0CB; color: #333; border: none; }
.type-Champagner { background-color: #E6C280; color: #333; border: none; }
.type-Suesswein { background-color: #F39C12; color: white; border: none; }

.location-list { 
    list-style: none; 
    margin-top: auto; 
    border-top: 1px solid #eee; 
    padding-top: 0.8rem; 
}
.location-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0.4rem 0; 
    font-size: 0.9rem; 
    border-bottom: 1px dashed #f5f5f5; 
}
.location-item:last-child { border-bottom: none; }

/* =======================================
   VISUELLES GESTELL (GRUNDGERÜST)
   ======================================= */
.visual-rack-box { 
    border-radius: 12px; 
    padding: 1rem; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    overflow-x: auto; 
    transition: all 0.4s ease; 
}

/* =======================================
   GESTELLE-THEMES (HINTERGRÜNDE - SEHR DEZENT)
   ======================================= */

/* 1. Holzgestell - Helles, sanftes Holz */
.theme-holzgestell {
    background-color: #fdf5e6; 
    background-image: repeating-linear-gradient(45deg, rgba(139,69,19,0.03) 0px, rgba(139,69,19,0.03) 2px, transparent 2px, transparent 6px);
    border: 2px solid #e3d0b9;
    color: #5c3a21; 
}
.theme-holzgestell .rack-row { border-bottom: 1px solid rgba(139,69,19,0.15); }
.theme-holzgestell .row-label { color: #8b5a2b; font-weight: bold; }
.theme-holzgestell .slot-empty { background: rgba(139,69,19,0.04); border-color: rgba(139,69,19,0.15); border-style: dashed; }

/* 2. Metallregal - Helles, sauberes Industrie-Grau */
.theme-metallregal {
    background-color: #f4f6f7;
    background-image: linear-gradient(90deg, rgba(44,62,80,0.03) 1px, transparent 1px), linear-gradient(rgba(44,62,80,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    border: 2px solid #bdc3c7;
    color: #2c3e50; 
}
.theme-metallregal .rack-row { border-bottom: 1px solid #bdc3c7; }
.theme-metallregal .row-label { color: #34495e; font-weight: bold; }
.theme-metallregal .slot-empty { background: rgba(44,62,80,0.03); border-color: #bdc3c7; border-style: dashed; }

/* 3. Weinklimaschrank - Elegantes, weiches Dunkelgrau */
.theme-weinklimaschrank {
    background-color: #23272b;
    background-image: none;
    border: 2px solid #3a3f47;
    color: #bdc3c7; 
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3); 
}
.theme-weinklimaschrank .rack-row { border-bottom: 1px solid #333; }
.theme-weinklimaschrank .row-label { color: #5dade2; font-weight: bold; } 
.theme-weinklimaschrank .slot-empty { background: rgba(255,255,255,0.03); border-color: #555; border-style: dashed; }

/* =======================================
   FÄCHER-DETAILS
   ======================================= */
.rack-row { 
    display: flex; 
    align-items: center; 
    margin-bottom: 0.8rem; 
    padding-bottom: 0.8rem; 
}
.rack-row:last-child { 
    margin-bottom: 0; 
    border-bottom: none; 
    padding-bottom: 0; 
}

.row-label { 
    width: 45px; 
    font-size: 0.9rem; 
    flex-shrink: 0; 
}

.rack-slots { 
    display: flex; 
    gap: 8px; 
    flex-grow: 1; 
    overflow-x: auto; 
    padding-bottom: 4px; 
    scrollbar-width: none;
    justify-content: space-between;
}
.rack-slots::-webkit-scrollbar { display: none; }

.rack-slot { 
    width: 42px; 
    height: 42px; 
    border-radius: 8px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    cursor: pointer; 
    flex-shrink: 0; 
    transition: transform 0.2s;
    position: relative; 
}
.rack-slot:active { transform: scale(0.9); }

.slot-filled { border: 1px solid transparent; } 
.slot-Rot { background: #fce8eb; border-color: #722F37; }
.slot-Weiss { background: #fffde6; border-color: #a5934f; }
.slot-Rose { background: #fff0f3; border-color: #FFC0CB; }
.slot-Champagner { background: #fcf6eb; border-color: #E6C280; }
.slot-Suesswein { background: #fdf2e9; border-color: #F39C12; }

.depth-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* =======================================
   MODAL (POPUP) FÜR DETAILS (GESTELLE)
   ======================================= */
.modal-overlay { 
    display: none; 
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.6); 
    z-index: 1000; 
    justify-content: center; 
    align-items: flex-end; 
    padding: 1rem; 
    opacity: 0; 
    transition: opacity 0.3s ease;
}
.modal-overlay.active { 
    display: flex; 
    opacity: 1; 
}

.modal-content { 
    background: white; 
    border-radius: 16px; 
    width: 100%; 
    max-width: 450px; 
    position: relative; 
    overflow: hidden; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); 
    transform: translateY(20px); 
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding-bottom: 1rem;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-close-btn { 
    position: absolute; 
    top: 10px; right: 10px; 
    background: rgba(0,0,0,0.5); 
    color: white; border: none; 
    width: 32px; height: 32px; 
    border-radius: 50%; 
    display: flex; justify-content: center; align-items: center; 
    font-size: 1rem; 
    cursor: pointer; 
    z-index: 10;
}

.modal-details-body { padding: 1.5rem; }

.modal-multiple-wines {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.modal-wine-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
}
.modal-wine-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
    cursor: pointer; 
}

/* =======================================
   LIGHTBOX 
   ======================================= */
#lightbox-prev,
#lightbox-next {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    border: none !important;
    width: 44px !important;       
    min-width: 44px !important;   
    max-width: 44px !important;
    height: 44px !important;      
    border-radius: 50% !important;
    padding: 0 !important;        
    margin: 0 !important;
    justify-content: center !important;
    align-items: center !important;
    font-size: 1.2rem !important;
    z-index: 2010 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
}

#lightbox-prev:hover,
#lightbox-next:hover {
    background: rgba(0, 0, 0, 0.9) !important;
}

#lightbox-prev { left: 15px !important; }
#lightbox-next { right: 15px !important; }

.lightbox-close-override {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    top: 20px !important;
    right: 20px !important;
}

/* =======================================
   UNTERE NAVIGATION (MOBILE)
   ======================================= */
.bottom-nav { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    background: white; 
    display: flex; 
    box-shadow: 0 -2px 15px rgba(0,0,0,0.08); 
    padding-bottom: env(safe-area-inset-bottom); 
    z-index: 100; 
}

.bottom-nav button { 
    flex: 1; 
    background: transparent; 
    color: #7f8c8d; 
    border-radius: 0; 
    font-size: 0.75rem; 
    padding: 0.8rem 0; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 4px; 
}

.bottom-nav button:active { 
    background: #f4f4f4; 
}

/* =======================================
   HIGHLIGHT & JUMP-ANIMATION 
   ======================================= */
.location-text { font-weight: 500; color: var(--success); }

.location-text.clickable {
    cursor: pointer;
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: color 0.2s;
}

.location-text.clickable:active {
    color: var(--primary-color);
}

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

.slot-highlight {
    border: none !important; 
    overflow: hidden; 
    box-shadow: 0 0 15px rgba(142, 68, 173, 0.5); 
}

.slot-highlight::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%; 
    z-index: 0;
    background: conic-gradient(transparent, var(--accent-color), transparent 30%);
    animation: rotateBorder 1s linear infinite;
}

.slot-highlight::after {
    content: '';
    position: absolute;
    inset: 3px; 
    background: inherit; 
    border-radius: 6px;
    z-index: 1;
}

.slot-highlight > svg,
.slot-highlight > .depth-badge {
    position: relative;
    z-index: 2;
}

/* =======================================
   TAP & MOVE (UMRÄUM-MODUS)
   ======================================= */
@keyframes pulseBanner {
    0% { box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(142, 68, 173, 0.7); }
    100% { box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3); }
}

#move-mode-banner {
    animation: pulseBanner 2s infinite;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

/* =======================================
   BARCODE SCANNER (CLEAN UI FIXES)
   ======================================= */
#qr-reader {
    border: none !important; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    background: #000;
}
#qr-reader video {
    border-radius: 8px !important;
    object-fit: cover !important;
}
/* Versteckt den hässlichen, automatischen Start-Button der Library, falls er aufblitzt */
#html5-qrcode-button-camera-start, #html5-qrcode-button-camera-stop {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    cursor: pointer;
}
