/* style.css (wersja 5.1 - Poprawka kolumn mobilnych Szybkich Akcji) */

html {
    background-color: #000000;
}
html, body {
    height: 100%;
}
:root {
    --font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
    --border-radius: 16px;
    --transition-speed: 0.4s;
    --alert-color: #ff4d4d;
}

/* ------------------- */
/* ----- MOTYW NOCNY (DOMYŚLNY) ----- */
/* ------------------- */
body.theme-night {
    --bg-color: transparent;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --accent-color: #0d8eff;
    --online-color: #28a745;
    --offline-color: #dc3545;
    --battery-medium-color: #f0ad4e;
    --card-hover-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
    --card-border-color: rgba(255, 255, 255, 0.1);
    --card-bg: linear-gradient(135deg, rgba(35, 35, 35, 0.5), rgba(30, 30, 30, 0.4));
    --device-row-bg: rgba(255, 255, 255, 0.05);
    /* Dodajemy tło dla przełącznika motywu */
    --theme-switch-bg: #333;
}
body.theme-night .logo-day { display: none !important; }
body.theme-night .logo-night { display: block !important; }

/* ------------------- */
/* ----- MOTYW DZIENNY ----- */
/* ------------------- */
body.theme-light {
    --bg-color: #f0f2f5;
    --text-primary: #1c1e21;
    --text-secondary: #606770;
    --accent-color: #007bff;
    --online-color: #28a745;
    --offline-color: #e02c2c;
    --battery-medium-color: #efa741;
    --card-hover-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
    --card-border-color: rgba(255, 255, 255, 0.3);
    --card-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(240, 242, 245, 0.5));
    --device-row-bg: #ffffff;
    /* Dodajemy tło dla przełącznika motywu */
    --theme-switch-bg: #ccc;
}
body.theme-light, body.theme-light html {
    background-color: #f0f2f5;
}
body.theme-light .logo-day { display: block !important; }
body.theme-light .logo-night { display: none !important; }

/* ------------------- */
/* ----- TŁO I STYLE OGÓLNE ----- */
/* ------------------- */
body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0; 
    transition: background-color var(--transition-speed), color var(--transition-speed);
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

@keyframes move-aurora {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -1;
    background: radial-gradient(at 15% 25%, rgba(13, 142, 255, 0.25) 0px, transparent 50%),
                radial-gradient(at 85% 75%, rgba(22, 163, 74, 0.2) 0px, transparent 50%);
    background-size: 200% 200%;
    animation: move-aurora 20s ease infinite;
    opacity: 0;
    transition: opacity 1s;
    will-change: opacity, background-position;
    transform: translateZ(0); 
}
body.theme-night::before {
    opacity: 1;
}

.header-top, .scenes-card, .dashboard-grid {
    padding-left: 20px;
    padding-right: 20px;
    position: relative;
    z-index: 1;
}
.header-top {
    padding-top: 20px;
}
.dashboard-grid {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.header-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; }
.header-left .logo img { height: 35px; }
.header-right { display: flex; align-items: center; gap: 16px; font-size: 0.95rem; color: var(--text-secondary); }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; }
.room-card { background: var(--card-bg); border: 1px solid var(--card-border-color); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: var(--border-radius); padding: 20px; box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; opacity: 0; animation: fadeInUp 0.5s ease-out forwards; }
.room-card:hover { transform: translateY(-5px); box-shadow: var(--card-hover-shadow); }
.room-card:nth-child(1) { animation-delay: 0.1s; }
.room-card:nth-child(2) { animation-delay: 0.2s; }
.room-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.scenes-card { 
    grid-column: 1 / -1;
    animation-delay: 0s !important;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 20px;
    box-shadow: none;
}
body.theme-light .scenes-card {
    background: transparent;
    box-shadow: none;
}
.scenes-card h2 {
    color: var(--text-primary);
    padding: 0 10px 12px 10px;
    border: none;
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.room-card h2 { margin-top: 0; color: var(--text-primary); border-bottom: 1px solid var(--card-border-color); padding-bottom: 12px; margin-bottom: 16px; font-size: 1.1rem; font-weight: 600; letter-spacing: 0.5px; }
.devices-list { display: flex; flex-direction: column; gap: 12px; }
.device-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    background: var(--device-row-bg);
    transition: background-color 0.2s, border-color 0.2s;
    border: 1px solid transparent;
    opacity: 0;
    animation: fadeInUpSmall 0.5s ease-out forwards;
    animation-delay: 0.2s;
}
.device-row[data-has-switch="1"] { cursor: pointer; }
.device-row[data-has-switch="1"]:hover { background-color: color-mix(in srgb, var(--accent-color) 10%, transparent); border-color: var(--accent-color); }
.device-name { display: flex; align-items: center; gap: 10px; font-weight: 500; flex-grow: 1; overflow: hidden; }

.status-indicator { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; color: var(--text-secondary); transition: color 0.3s; }
.device-row.online .status-indicator { color: var(--online-color); }

.device-status {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-width: 0;
}
.device-row-full-width .device-status { flex-grow: 1; }

.device-status .value i { font-size: 1rem; margin-right: 6px; color: var(--text-secondary); width: 20px; text-align: center; }
.value, .value-extra, .value-offline { font-feature-settings: 'tnum'; }
.value { font-weight: 600; }
.value-offline { color: var(--offline-color); font-style: italic; font-size: 0.9rem; font-weight: 500; }
.sensor-value-wrapper, .offline-wrapper { text-align: right; }
.last-changed, .last-seen { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; margin-top: 4px; }
.last-seen { font-style: italic;}

.battery-indicator { display: inline-flex; align-items: center; margin-left: auto; padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; background-color: color-mix(in srgb, var(--card-border-color) 50%, transparent); flex-shrink: 0; }
.battery-indicator.battery-high { color: var(--online-color); }
.battery-indicator.battery-medium { color: var(--battery-medium-color); }
.battery-indicator.battery-low { color: var(--offline-color); }

.weather-widget { display: flex; flex-direction: column; width: 100%; gap: 16px; padding: 0; background: transparent; }
.weather-main-panel { text-align: center; border-bottom: 1px solid var(--card-border-color); padding-bottom: 16px; }
.weather-icon { font-size: 3.5rem; color: var(--accent-color); margin-bottom: 8px; }
.weather-temp { font-size: 2.8rem; font-weight: 700; line-height: 1; }
.weather-status-text { font-size: 1rem; color: var(--text-secondary); margin-top: 4px; }
.weather-forecast { font-size: 0.9rem; color: var(--text-primary); margin-top: 8px; font-style: italic; font-weight: 500; }
.weather-details-panel { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 16px; font-size: 0.9rem; }
.detail-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-secondary); }
.detail-item i { width: 16px; text-align: center; }
.detail-item span { white-space: nowrap; }
.detail-item strong { color: var(--text-primary); font-weight: 600; }
.pressure-trend { display: inline-block; }
.pressure-trend.fa-arrow-trend-up { color: var(--online-color); }
.pressure-trend.fa-arrow-trend-down { color: var(--offline-color); }
@keyframes pulse-red { 0% { background-color: var(--device-row-bg); box-shadow: 0 0 0 0 color-mix(in srgb, var(--alert-color) 40%, transparent); } 70% { background-color: color-mix(in srgb, var(--alert-color) 25%, transparent); box-shadow: 0 0 10px 12px transparent; } 100% { background-color: var(--device-row-bg); box-shadow: 0 0 0 0 transparent; } }
.device-row.alert-active { border-color: var(--alert-color); animation: pulse-red 2s infinite; }
.device-row.alert-active .device-name .fa-land-mine-on { color: var(--alert-color) !important; }

/* === POCZĄTEK NOWEGO STYLU PRZEŁĄCZNIKA (Solid) === */
.switch { 
    position: relative; 
    display: inline-block; 
    width: 46px; 
    height: 26px; 
}
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--device-row-bg); 
    border: 1px solid var(--card-border-color);
    border-radius: 26px;
    transition: var(--transition-speed);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: #f0f0f0; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: var(--transition-speed);
    border-radius: 50%;
}

.device-row[data-has-switch="1"]:hover .slider {
    border-color: var(--accent-color);
}

input:checked + .slider {
    background-color: color-mix(in srgb, var(--accent-color) 80%, #000 20%);
    border-color: color-mix(in srgb, var(--accent-color) 80%, #000 20%);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: #f0f0f0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:disabled + .slider { 
    cursor: not-allowed; 
    opacity: 0.5; 
}

/* --- Poprawki dla motywu jasnego --- */
body.theme-light .slider {
    background-color: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}
body.theme-light .slider:before {
    background-color: #e9e9e9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.theme-light input:checked + .slider {
     background-color: color-mix(in srgb, var(--accent-color) 80%, #000 20%);
     border-color: color-mix(in srgb, var(--accent-color) 80%, #000 20%);
}
body.theme-light input:checked + .slider:before {
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* === KONIEC NOWEGO STYLU PRZEŁĄCZNIKA === */

.theme-switcher { position: relative; }
.theme-switcher input { display: none; }
.theme-switcher label { cursor: pointer; display: flex; align-items: center; justify-content: center; width: 50px; height: 28px; background-color: var(--theme-switch-bg); border-radius: 28px; position: relative; font-size: 14px; transition: var(--transition-speed); }
.theme-switcher label .sun, .theme-switcher label .moon { position: absolute; transition: opacity 0.3s, transform 0.3s; }
.theme-switcher label .sun { opacity: 0; transform: translateY(5px); }
.theme-switcher label .moon { opacity: 1; transform: translateY(0); }
.theme-switcher input:checked ~ label .sun { opacity: 1; transform: translateY(0); }
.theme-switcher input:checked ~ label .moon { opacity: 0; transform: translateY(-5px); }

.pin-overlay { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1000; display: flex; align-items: center; justify-content: center; background-color: rgba(20, 22, 30, 0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pin-container { background: var(--card-bg); padding: 30px; border-radius: 16px; width: 90%; max-width: 320px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); border: 1px solid var(--card-border-color); text-align: center; color: var(--text-primary); }
.pin-container h2 { margin-top: 0; margin-bottom: 20px; font-size: 1.2rem; font-weight: 600; color: var(--text-primary); }
.pin-container .pin-input { width: 100%; padding: 12px; font-size: 1.5rem; letter-spacing: 0.5em; text-align: center; border-radius: 8px; border: 1px solid var(--card-border-color); background: var(--bg-color); color: var(--text-primary); margin-bottom: 20px; box-sizing: border-box; }
.pin-container .pin-input:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 25%, transparent); }
.pin-container .pin-submit { width: 100%; padding: 12px; font-size: 1rem; font-weight: 600; border-radius: 8px; border: none; background-color: var(--accent-color); color: white; cursor: pointer; transition: filter 0.2s; }
.pin-container .pin-submit:hover { filter: brightness(0.9); }
.pin-container .pin-error { color: #ff6b6b; margin-top: 15px; font-size: 0.9rem; min-height: 1.2em; }
.pin-logo { margin-top: 25px; text-align: center; }
.pin-logo-img { width: 120px; opacity: 0.85; transition: opacity 0.3s ease; }
.pin-logo-img:hover { opacity: 1; }
.scenes-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.scene-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--device-row-bg);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scene-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-button:hover {
    background-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
    border-color: var(--accent-color);
    transform: translateY(-3px) scale(1.03);
}
.scene-button i { font-size: 1rem; color: var(--accent-color); width: 20px; text-align: center; flex-shrink: 0; }
.scene-button:disabled { cursor: not-allowed; opacity: 0.6; background-color: var(--device-row-bg); border-color: transparent; }
.small-note .fa-arrows-rotate {
  margin-right: 8px;
}
/* ----- NOWE STYLE SPOTIFY ----- */
.spotify-card {
    grid-column: 1 / -1; /* Pełna szerokość w siatce */
    background: var(--grid-bg, linear-gradient(135deg, rgba(35, 35, 35, 0.5), rgba(30, 30, 30, 0.4))); /* Tło z grid lub glass */
    border: 1px solid var(--grid-border-color, var(--card-border-color)); /* Ramka z grid lub glass */
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    /* Animacja pojawiania się (jeśli używasz) */
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    filter: blur(3px);
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition-delay: 0s; /* Pojawia się jako pierwszy */
}
.spotify-card.is-visible { /* Klasa dodawana przez JS od animacji */
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
}
/* Poprawka dla Glass */
body.glass .spotify-card {
    border-radius: var(--border-radius);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.5s ease-out forwards; /* Używamy animacji z Glass */
    transition: none; /* Wyłączamy transition z Grid */
}


.spotify-connect-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background-color: #1DB954; /* Kolor Spotify */
    color: #ffffff;
    border: none;
    border-radius: 50px; /* Zaokrąglony */
    font-weight: bold;
    text-decoration: none;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}
.spotify-connect-button:hover {
    background-color: #1ED760;
}
.spotify-connect-button i {
    font-size: 1.2rem;
}

#spotify-widget {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.spotify-album-art img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.spotify-album-art.no-art {
    width: 80px;
    height: 80px;
    background-color: rgba(128, 128, 128, 0.3); /* Szare tło dla braku okładki */
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: rgba(255,255,255, 0.5);
}


.spotify-track-info {
    flex-grow: 1;
    overflow: hidden; /* Zapobiega wypychaniu przez długie nazwy */
    text-align: left;
}

.spotify-track-title {
    font-size: 1.1rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Dodaje '...' dla za długich tytułów */
    margin: 0;
}

.spotify-artist-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 4px 0 0 0;
}

.spotify-controls button {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem; /* Większe ikony */
    cursor: pointer;
    padding: 5px;
    margin: 0 5px;
    transition: color 0.2s, transform 0.2s;
}
.spotify-controls button:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}
.spotify-controls button:disabled {
    color: var(--text-secondary);
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.spotify-controls .play-pause-btn i { /* Specjalnie dla play/pause */
   font-size: 1.8rem; /* Jeszcze większa ikona play/pause */
}

.spotify-device-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: center; /* Wycentrowanie info o urządzeniu */
    width: 100%; /* Rozciągnij pod całością */
    display: none; /* Domyślnie ukryte, pokażemy gdy są dane */
}
#spotify-widget.has-device .spotify-device-info {
    display: block; /* Pokaż gdy są dane */
}

/* Dostosowanie na mobilce (jeśli siatka kontenera Spotify jest inna) */
@media (max-width: 768px) {
    #spotify-widget {
        flex-direction: column; /* Ułóż w kolumnie */
        text-align: center;
        gap: 10px;
    }
    .spotify-track-info {
        text-align: center; /* Wycentruj tekst */
    }
    .spotify-controls {
        margin-top: 5px;
    }
}

/* ----- KONIEC STYLI SPOTIFY ----- */
@media (max-width: 768px) { 
    .header-top { 
        flex-wrap: wrap;
        gap: 15px;
    } 
    .dashboard-grid { grid-template-columns: 1fr; } 
    .header-right { 
        gap: 12px;
        flex-grow: 1;
        justify-content: flex-end;
    } 
    
    /* ZMIANA: 4 kolumny dla Szybkich Akcji na mobile */
    .scenes-list {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    .scene-button {
        font-size: 0.75rem; /* Dopasowanie czcionki */
        padding: 10px; /* Mniejszy padding */
        gap: 8px; /* Mniejszy odstęp w przycisku */
    }
    /* Koniec zmiany */
}


/* === DODANE ANIMACJE (PROPOZYCJE 1, 2, 3) === */
@keyframes fadeInUpSmall {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.device-row:nth-child(2) { animation-delay: 0.25s; }
.device-row:nth-child(3) { animation-delay: 0.3s; }
.device-row:nth-child(4) { animation-delay: 0.35s; }
.device-row:nth-child(5) { animation-delay: 0.4s; }
.device-row:nth-child(6) { animation-delay: 0.45s; }
.device-row:nth-child(7) { animation-delay: 0.5s; }
.device-row:nth-child(8) { animation-delay: 0.55s; }
.device-row:nth-child(9) { animation-delay: 0.6s; }
.device-row:nth-child(10) { animation-delay: 0.65s; }

.header-left .logo,
.header-right .date,
.header-right .small-note,
.header-right .theme-switcher {
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}
.header-left .logo { animation-delay: 0.1s; }
.header-right .date { animation-delay: 0.2s; }
.header-right .small-note { animation-delay: 0.3s; }
.header-right .theme-switcher { animation-delay: 0.4s; }