/* Temperature Monitor - Modern Mobile-First Design */
/* Version 2.0 - Mit Landscape Support */

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-light: #1e293b;
    --bg-card: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    position: relative;
}

.install-btn {
    position: absolute;
    right: 0;
    top: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.install-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.install-btn:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Aktuelle Temperatur - Große Anzeige */
.current-temp-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 24px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.3);
    text-align: center;
    position: relative;
}

.temp-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 20px;
}

.temp-value {
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.temp-unit {
    font-size: 3rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-left: 10px;
}

.temp-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

#last-update {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}

/* DB Info Badge - oben rechts in der Ecke */
.db-info-corner {
    position: absolute;
    top: 15px;
    right: 15px;
}

.db-count-badge {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 12px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: inline-block;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 30px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.refresh-btn:active {
    transform: translateY(0);
}

.refresh-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Statistiken Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    overflow-x: auto;
    padding-bottom: 5px;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.filter-btn:hover {
    border-color: var(--primary);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: transparent;
    color: white;
}

/* Chart Container - D3.js */
.chart-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    width: 100%;
    position: relative;
    min-height: 300px;
    touch-action: pan-y pinch-zoom;
}

#d3-chart {
    width: 100%;
    height: 100%;
    min-height: 280px;
}

#d3-chart svg {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
}

.zoom-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 20px;
    padding: 8px;
    background: var(--bg-light);
    border-radius: 8px;
}

/* Custom Range Container */
.custom-range-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-range-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 15px;
    align-items: end;
}

.date-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-input-group label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.date-input {
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.apply-custom-btn,
.cancel-custom-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    white-space: nowrap;
}

.apply-custom-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.apply-custom-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.cancel-custom-btn {
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text);
}

.cancel-custom-btn:hover {
    background: var(--bg-light);
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer .small {
    font-size: 0.8rem;
    margin-top: 5px;
}

/* ========== LANDSCAPE MODUS ========== */
@media (orientation: landscape) {
    .container {
        padding: 10px 20px;
    }
    
    header {
        margin-bottom: 15px;
        padding: 10px 0;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .current-temp-card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .temp-value {
        font-size: 3.5rem;
    }
    
    .temp-unit {
        font-size: 1.8rem;
    }
    
    .temp-info {
        flex-direction: row;
        gap: 20px;
    }
    
    .stats-grid {
        margin-bottom: 15px;
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .filter-tabs {
        margin-bottom: 15px;
        gap: 8px;
    }
    
    .filter-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .chart-container {
        padding: 15px;
        margin-bottom: 15px;
        /* Im Landscape: Chart nimmt mehr Platz ein */
        min-height: 200px;
    }
    
    #temperatureChart {
        min-height: 180px;
    }
    
    footer {
        padding: 15px 0;
    }
}

/* ========== MOBILE PORTRAIT ========== */
@media (max-width: 768px) and (orientation: portrait) {
    .back-button {
        position: relative;
        left: auto;
        top: auto;
        margin-bottom: 15px;
        display: inline-block;
    }
    
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .temp-value {
        font-size: 4.5rem;
    }
    
    .temp-unit {
        font-size: 2rem;
    }
    
    .current-temp-card {
        padding: 30px 20px;
    }
    
    .db-info-corner {
        top: 10px;
        right: 10px;
    }
    
    .db-count-badge {
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .filter-tabs {
        gap: 8px;
    }
    
    .filter-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .custom-range-inputs {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .apply-custom-btn,
    .cancel-custom-btn {
        width: 100%;
    }
    
    .chart-container {
        min-height: 300px;
    }
    
    #temperatureChart {
        min-height: 250px;
    }
}

/* ========== MOBILE LANDSCAPE ========== */
@media (max-width: 900px) and (orientation: landscape) {
    .container {
        padding: 8px 15px;
    }
    
    header {
        margin-bottom: 10px;
        padding: 5px 0;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        display: none;
    }
    
    .install-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        top: 5px;
    }
    
    .current-temp-card {
        padding: 15px;
        margin-bottom: 10px;
        border-radius: 16px;
    }
    
    .temp-display {
        margin-bottom: 10px;
    }
    
    .temp-value {
        font-size: 2.8rem;
    }
    
    .temp-unit {
        font-size: 1.5rem;
    }
    
    .temp-info {
        flex-direction: row;
        gap: 15px;
    }
    
    #last-update {
        font-size: 0.85rem;
    }
    
    .refresh-btn {
        padding: 8px 20px;
        font-size: 0.85rem;
    }
    
    .db-info-corner {
        top: 8px;
        right: 8px;
    }
    
    .db-count-badge {
        font-size: 0.6rem;
        padding: 3px 8px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 10px;
    }
    
    .stat-card {
        padding: 10px;
        border-radius: 12px;
    }
    
    .stat-label {
        font-size: 0.7rem;
        margin-bottom: 4px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .filter-tabs {
        margin-bottom: 10px;
        gap: 6px;
    }
    
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
        border-radius: 8px;
    }
    
    .chart-container {
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 12px;
        /* Im Landscape: Chart groß und zoombar */
        min-height: 150px;
        height: calc(100vh - 280px);
        max-height: 400px;
    }
    
    #temperatureChart {
        min-height: 130px;
        height: 100%;
    }
    
    footer {
        padding: 10px 0;
        font-size: 0.75rem;
    }
    
    footer .small {
        display: none;
    }
    
    .custom-range-container {
        padding: 15px;
    }
    
    .custom-range-inputs {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 10px;
    }
}

/* Loading Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading .refresh-btn::before {
    content: "⏳ ";
    animation: spin 1s linear infinite;
}
