:root {
    --primary-color: #2e7d32;
    --primary-color-light: #4caf50;
    --primary-color-dark: #1b5e20;
    --accent-color: #00c853;
    --accent-color-light: #69f0ae;
    --background-color: #0a0a0a;
    --card-background: #1c1c1c;
    --card-background-hover: #282828;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --success-color: #00c853;
    --error-color: #ff5252;
    --border-radius: 20px;
    --button-radius: 50px;
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --glow: 0 0 20px rgba(76, 175, 80, 0.5);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
        Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
        'Apple Color Emoji', 'Segoe UI Emoji';
    background-color: var(--background-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(46, 125, 50, 0.03) 0%, transparent 70%),
        radial-gradient(circle at 90% 80%, rgba(0, 200, 83, 0.03) 0%, transparent 70%);
    color: var(--text-color);
    line-height: 1.6;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 40px;
    color: var(--text-color);
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding-top: 25px;
    position: relative;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

h1::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Ikona žárovky odstraněna z nadpisu */

.sensor-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 30px;
    width: 100%;
}

.sensor {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(10px);
    margin: 10px 0;
}

.sensor::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 3px;
}

.sensor:hover {
    transform: translateY(-8px);
    background-color: var(--card-background-hover);
    box-shadow: var(--glow);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.sensor h2 {
    margin-top: 10px;
    margin-bottom: 10px;
    color: var(--text-color);
    text-align: center;
    font-size: 1.5rem;
    font-weight: 500;
}

.sensor-description {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    font-style: italic;
}

.state {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 20px 0;
    padding: 18px;
    background-color: rgba(255, 255, 255, 0.07);
    border-radius: var(--border-radius);
    text-align: center;
    letter-spacing: 0.5px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2);
    border-left: 4px solid var(--primary-color);
}

.buttons {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    justify-content: center;
    flex-direction: column;
}

.btn {
    flex: 1;
    padding: 16px 22px; /* větší cílová plocha */
    border: none;
    border-radius: var(--button-radius);
    cursor: pointer;
    color: white;
    font-weight: 500;
    text-align: center;
    background-color: rgba(46, 125, 50, 0.9);
    transition: var(--transition);
    min-width: 80px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.95rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

/* Indikátor dnešních časů */
.iot-indicator {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.today-extra { margin-top: 6px; display: none; }
.interval-row { color: var(--text-secondary); font-size: 0.9rem; padding: 2px 0; }
.extra-row { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.extra-off { position: relative; display: inline-block; }
.extra-off .icon-remove { position: absolute; right: 8px; top: 8px; color: #ff5252; cursor: pointer; opacity: 0; transition: opacity .15s ease; font-size: 14px; }
.extra-off:hover .icon-remove { opacity: 1; }
/* řádky dalších dnešních oken používají stejné field styly */
.iot-chip {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: var(--text-color);
    font-size: 0.8rem;
    cursor: pointer;
}
.iot-chip-edit { background: rgba(76,175,80,0.18); }

/* Jemné zvýraznění po uložení */
.flash {
    animation: flash-bg 0.6s ease;
}
@keyframes flash-bg {
    0% { box-shadow: 0 0 0 rgba(76,175,80,0); }
    50% { box-shadow: 0 0 12px rgba(76,175,80,0.9); }
    100% { box-shadow: 0 0 0 rgba(76,175,80,0); }
}

/* Sticky akce v bublinách */
.picker-popover .picker-actions {
    position: sticky;
    bottom: 0;
    background: var(--card-background);
    padding: 8px;
}

/* Mobilní bottom-sheet pro týdenní bublinu */
.picker-popover.sheet {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-height: 70vh;
    overflow: auto;
    z-index: 1100;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Žluté plus bez pozadí */
.plus-btn {
  background: transparent;
  color: #ffd54f;
  border: 2px solid #ffd54f;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 14px;
}
.plus-btn:hover { background: rgba(255,213,79,0.12); }

/* Větší selecty + zabránění iOS zoomu */
.iot-select {
    font-size: 16px;
    min-height: 44px;
}

/* Časový přepínač (dočasné) aktivní stav */
.active-temp {
    box-shadow: 0 0 12px rgba(0,200,83,0.6);
}

/* Popover/Sheet */
.ui-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: start; justify-content: center; padding: 16px; z-index: 1000; transition: opacity .15s ease;
}
.ui-overlay.hidden { opacity: 0; pointer-events: none; }
.ui-panel {
    background: var(--card-background); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; max-width: 520px; width: 100%; padding: 12px; box-shadow: var(--box-shadow);
}
.ui-panel.sheet { align-self: flex-end; width: 100%; max-width: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 70vh; overflow: auto; }
.panel-title { font-weight: 600; margin: 6px 6px 12px; }
.panel-body { display: flex; flex-direction: column; gap: 8px; padding: 0 6px 8px; }
.panel-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 6px 0; position: sticky; bottom: 0; background: var(--card-background); }
.editor-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)) auto; gap: 8px; align-items: center; }
.tog-btn.danger { background: #b00020; }

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn:hover::after {
    left: 100%;
}

.btn:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.active {
    background-color: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-color-light);
    transform: scale(1.05);
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* IoT UI */
.iot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.iot-card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 18px;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Pilulka režimu u titulku */
/* pilulka režimu odstraněna */

.iot-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
    text-align: center;
    cursor: pointer;
}

.iot-title.editing { cursor: text; }
.iot-title .iot-id { opacity: 0.7; font-weight: 400; }
.title-input { width: 100%; text-align: center; }

.iot-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
    align-items: center;
    width: 100%;
    position: relative;
}

.iot-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.time-display {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    display: inline-block;
    cursor: pointer;
}

.time-display.active-temp {
    background-color: var(--accent-color);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    box-shadow: 0 0 12px var(--accent-color-light);
    font-weight: 600;
}

.picker-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    transform: none;
    width: auto;
    min-width: 280px;
    max-width: calc(100vw - 32px);
    background-color: var(--card-background);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.5);
    padding: 12px;
    z-index: 2000;
    backdrop-filter: blur(6px);
}
.picker-panel.open { display: block; }

.picker-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    transform: none;
    width: auto;
    min-width: 280px;
    max-width: calc(100vw - 32px);
    background-color: var(--card-background);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.5);
    padding: 12px;
    z-index: 2000;
    backdrop-filter: blur(6px);
}
.picker-popover.open { display: block; }

.iot-input, .iot-select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.iot-time {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.iot-time .picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 1rem;
    min-width: 76px;
    text-align: center;
}

.iot-time-sep {
    opacity: 0.7;
}

.iot-row {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Zapnutí a vypnutí vedle sebe */
    gap: 10px;
    justify-items: center;
    width: 100%;
}

.day-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.time-display-btn {
    min-width: 110px;
}

/* Tři prvky (Zapnutí) (Dnes) (Vypnutí) na jednom řádku uprostřed */
.iot-row.inline-three {
    grid-template-columns: auto auto auto;
    justify-content: center;
    align-items: start;
}
.iot-row.inline-three .iot-field { width: auto; }
.iot-row.inline-three .iot-label { text-align: center; }
.day-spacer { min-width: 80px; }

.iot-status {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.iot-temp {
    display: grid;
    grid-template-columns: 1fr; /* stacked: controls then wheels */
    gap: 10px;
    justify-items: center;
    width: 100%;
}

.iot-temp .tog-btn { width: 100%; }

@media (max-width: 600px) {
  .iot-temp { grid-template-columns: 1fr; }
}

/* Wheel picker look (Android/iOS-like) */
.picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.picker-stacked {
    grid-template-columns: 1fr;
}

.picker-col {
    position: relative;
    width: 100%;
    max-width: 200px;
}

.picker-viewport {
    height: 144px; /* 4 items visible (including above/below) */
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(4px);
    position: relative;
}

.picker-item {
    height: 36px;
    line-height: 36px;
    text-align: center;
    font-size: 1.05rem;
    color: var(--text-color);
    scroll-snap-align: center;
}

/* Odstranění oddělujících čar ve výběru */
.picker-col::after { display: none; content: none; border: 0; }

.picker-label {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.picker-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.select-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.select-row .iot-select { min-width: 90px; }

.icon-clear {
    color: var(--error-color);
    cursor: pointer;
    font-weight: 700;
    align-self: center;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 82, 82, 0.4);
    background: rgba(255, 82, 82, 0.08);
}
.icon-clear:hover {
    background: rgba(255, 82, 82, 0.18);
}

/* Třístavový přepínač (Auto / Zap / Vyp) */
.iot-toggle {
    display: grid;
    grid-template-columns: repeat(3, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 6px;
    justify-items: center;
    width: 100%;
}
.iot-toggle .tog-btn.copy-target { box-shadow: 0 0 12px rgba(76,175,80,0.8); }

.tog-btn {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    min-width: 88px;
}

.tog-btn:hover {
    background-color: var(--card-background-hover);
    filter: brightness(1.1);
}

.tog-btn.active {
    background-color: var(--accent-color);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    box-shadow: 0 0 12px var(--accent-color-light);
    font-weight: 600;
}

/* Mobilní optimalizace */
@media (max-width: 600px) {
  .container { padding: 16px; }
  .iot-grid { gap: 12px; }
  .iot-card { padding: 14px; }
  .iot-input, .iot-select, .tog-btn { padding: 12px 14px; font-size: 1rem; }
  .iot-row { grid-template-columns: 1fr; }
  .iot-title { font-size: 1.05rem; }
  .iot-label { font-size: 0.95rem; }
  .state, .status-message { font-size: 1rem; }
  .iot-toggle { grid-template-columns: 1fr 1fr 1fr; }
  .iot-time .picker { min-width: 86px; }
}

.active:hover {
    background-color: var(--accent-color-light);
}

.active::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7);
    top: 10px;
    left: 10px;
    box-shadow: 0 0 10px white;
}

.status-container {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 1000;
}

.status-message {
    padding: 12px 25px;
    border-radius: 30px;
    font-weight: 500;
    text-align: center;
    box-shadow: var(--box-shadow);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    max-width: 90%;
    backdrop-filter: blur(10px);
}

.status-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.success {
    background-color: rgba(0, 200, 83, 0.8);
    color: white;
}

.error {
    background-color: rgba(255, 82, 82, 0.8);
    color: white;
}

.loading {
    background-color: rgba(46, 125, 50, 0.8);
    color: white;
}

.update-time {
    text-align: center;
    font-size: 0.95rem;
    color: var(--accent-color-light);
    margin-bottom: 30px;
    padding: 12px 20px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50px;
    display: inline-block;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid rgba(76, 175, 80, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    font-weight: 500;
    letter-spacing: 1px;
}

.time-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 15px;
    position: relative;
}

.update-time::before {
    content: '⏱️';
    margin-right: 8px;
}

/* Animace pro tlačítka */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.btn:active {
    animation: pulse 0.3s ease;
}

/* Media queries pro mobilní zařízení */
@media (min-width: 600px) {
    .buttons {
        flex-direction: row;
    }
    /* Senzory ponechány vždy pod sebou */
}
