/* AI Grow / Timer Grow switcher (both pages) + the Timer Grow page (/timer, body.tp).
   Everything for the timer page is under .tp, so nothing here restyles the AI page. */

.grow-switch {
    display: inline-flex;
    gap: 0.35rem;
    margin-bottom: 1rem;
    padding: 0.3rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
}
.grow-switch-btn {
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: transparent; border: none; color: var(--text-muted);
    padding: 0.5rem 1.1rem; border-radius: 8px; cursor: pointer;
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
    transition: background 0.2s, color 0.2s;
}
.grow-switch-btn svg { width: 16px; height: 16px; }
.grow-switch-btn:hover { color: var(--text-main); }
.grow-switch-btn.active { background: var(--panel-border); color: #fff; }
.grow-switch-btn.active svg { color: var(--accent); }


.timer-schedule { display: flex; flex-direction: column; gap: 0.6rem; }
.sched-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    font-size: 0.9rem;
}
.sched-row > svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.sched-row .sched-label { color: var(--text-muted); min-width: 110px; }
.sched-row .sched-val { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.sched-chip {
    font-family: 'JetBrains Mono', monospace; font-size: 0.8rem;
    padding: 0.15rem 0.5rem; border-radius: 6px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
}
.sched-chip.done { color: var(--accent); border-color: rgba(16,185,129,0.35); }
.sched-chip.next { color: var(--blue); border-color: rgba(59,130,246,0.45); }

.log-item.timer-event { border-left-color: var(--blue); }
.log-item.timer-err { border-left-color: var(--amber); }
.log-item.timer-err.level-error { border-left-color: var(--red); }
.timer-errors .log-reason { margin-bottom: 0; font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }


/* ── Timer page ────────────────────────────────────────────────────── */

.tp .stat-val { font-size: 1.3rem; }
.tp .log-feed { max-height: 420px; }
.tp .mt-4 { margin-top: 1.25rem; }
.tp .hint-inline { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); margin-left: 0.4rem; }

.tp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; }
.tp-grid > * { min-width: 0; }
.tp-span { grid-column: 1 / -1; }
@media (max-width: 1000px) { .tp-grid { grid-template-columns: minmax(0, 1fr); } }

.tp-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--panel-border); margin-bottom: 1.5rem; overflow-x: auto; }
.tp-tab {
    display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap;
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-muted); padding: 0.7rem 1rem; cursor: pointer;
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
}
.tp-tab svg { width: 16px; height: 16px; }
.tp-tab:hover { color: var(--text-main); }
.tp-tab.active { color: var(--text-main); border-bottom-color: var(--accent); }
.tp-tab.active svg { color: var(--accent); }
.tp-section { display: none; }
.tp-section.active { display: block; }
.tp-tracker { margin: -0.75rem 0 1rem; }
.tp-tracker:empty { display: none; }
.tp-lead { margin: 0 0 1rem; }
.tp-lead > svg { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 0.3rem; }
.tp-lead .small-btn { margin-left: 0.5rem; vertical-align: middle; }

/* latest photos: plant + dashboard side by side */
.tp-latest { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.tp-cam { margin: 0; }
.tp-cam img { cursor: zoom-in; background: rgba(255,255,255,0.03); min-height: 120px; }
.tp-cam img:not([src]), .tp-cam img[src=""] { visibility: hidden; }
.tp-cam.empty::before {
    content: "No photo yet"; position: absolute; inset: 0; display: grid; place-items: center;
    color: var(--text-muted); font-size: 0.9rem; border: 1px dashed var(--panel-border); border-radius: 12px;
}
.tp-stats { grid-template-columns: repeat(4, 1fr); margin-top: 1rem; }
@media (max-width: 900px) { .tp-latest, .tp-stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .tp-latest { grid-template-columns: 1fr; } }

/* today's timeline */
.tp-today { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tp-today .slot {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.65rem; border-radius: 8px; font-size: 0.82rem;
    background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
}
.tp-today .slot svg { width: 14px; height: 14px; }
.tp-today .slot.done { color: var(--accent); border-color: rgba(16,185,129,0.35); }
.tp-today .slot.now { color: #fff; border-color: var(--blue); background: rgba(59,130,246,0.15); }
.tp-today .slot.missed { color: var(--amber); border-color: rgba(245,158,11,0.4); }
.tp-today .slot.later { color: var(--text-muted); }

/* tables */
.tp-table-wrap { overflow-x: auto; }
.tp-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tp-table th, .tp-table td { padding: 0.5rem 0.75rem; text-align: right; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }
.tp-table th:first-child, .tp-table td:first-child { text-align: left; }
.tp-table th { color: var(--text-muted); font-weight: 500; }
.tp-table td.num { font-family: 'JetBrains Mono', monospace; }

/* segmented buttons, chips, inputs */
.tp-seg { display: inline-flex; padding: 0.2rem; gap: 0.2rem; background: rgba(0,0,0,0.3); border-radius: 9px; }
.tp-seg button {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 0.4rem 0.8rem; border-radius: 7px; font-family: inherit; font-size: 0.85rem; font-weight: 600;
}
.tp-seg.small button { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.tp-seg button svg { width: 15px; height: 15px; }
.tp-seg button.active { background: var(--panel-border); color: #fff; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tp-chips button {
    background: rgba(255,255,255,0.04); color: var(--text-muted); border: 1px solid var(--panel-border);
    padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 0.8rem;
}
.tp-chips button.active { color: #fff; border-color: var(--accent); background: var(--accent-glow); }
.tp-chips button .n { opacity: 0.6; margin-left: 0.25rem; }
.tp input[type=text], .tp input[type=number], .tp select, .tp textarea {
    background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border);
    color: var(--text-main); border-radius: 8px; padding: 0.45rem 0.6rem;
    font-family: inherit; font-size: 0.85rem; outline: none; min-width: 0;
}
.tp input[type=number] { width: 5.5rem; }
.tp input:focus, .tp select:focus, .tp textarea:focus { border-color: var(--accent); }
.tp select option { background: #0d1220; }
.tp label { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.83rem; color: var(--text-muted); }
.tp textarea.code-editor {
    width: 100%; min-height: 260px; margin-top: 0.6rem; resize: vertical;
    font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; line-height: 1.5; tab-size: 4;
    background: rgba(0,0,0,0.35);
}
.tp textarea.code-editor.tall { min-height: 420px; }
.tp textarea[readonly] { color: var(--text-muted); }
.tp #code-file { min-width: 220px; }
.tp .cc-card .flex-between { flex-wrap: wrap; gap: 0.6rem; }
.tp .cc-card.on { border-color: rgba(16,185,129,0.45); box-shadow: 0 0 0 1px rgba(16,185,129,0.15) inset; }

/* photos tab */
.tp-photo-bar { flex-wrap: wrap; gap: 0.75rem; }
.tp-photo-filters { display: flex; align-items: center; gap: 0.6rem; }
.tp .gallery-item { cursor: zoom-in; }
.tp .gallery-item.pair { aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #000; }
.tp .gallery-item.pair img { aspect-ratio: 16/9; }
.tp .gallery-item .missing { display: grid; place-items: center; color: var(--text-muted); font-size: 0.75rem; aspect-ratio: 16/9; background: rgba(255,255,255,0.03); }
.tp-day-head { grid-column: 1 / -1; color: var(--text-muted); font-size: 0.85rem; font-weight: 600; margin-top: 0.5rem; }

.tp-pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; font-size: 0.85rem; color: var(--text-muted); }
.tp-pagination:empty { display: none; }
.tp-pagination button {
    background: rgba(255,255,255,0.06); color: var(--text-main);
    border: 1px solid var(--panel-border); border-radius: 6px;
    padding: 0.35rem 0.8rem; cursor: pointer; font-family: inherit;
}
.tp-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* decision log */
.tp-log { display: flex; flex-direction: column; margin-top: 0.75rem; }
.tp-log .day { position: sticky; top: 0; z-index: 1; background: #0f1524; padding: 0.5rem 0; margin-top: 0.5rem;
    color: var(--text-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--panel-border); }
.tp-log .ev { display: grid; grid-template-columns: 4.5rem 1.4rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: start;
    padding: 0.5rem 0.25rem; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.86rem; }
.tp-log .ev .t { font-family: 'JetBrains Mono', monospace; color: var(--text-muted); font-size: 0.78rem; padding-top: 0.1rem; }
.tp-log .ev > svg { width: 16px; height: 16px; color: var(--text-muted); margin-top: 0.1rem; }
.tp-log .ev .why { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; overflow-wrap: anywhere; }
.tp-log .ev .src { font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 6px; border: 1px solid var(--panel-border); color: var(--text-muted); white-space: nowrap; }
.tp-log .ev .src.schedule { color: var(--blue); border-color: rgba(59,130,246,0.4); }
.tp-log .ev .src.manual { color: var(--amber); border-color: rgba(245,158,11,0.4); }
.tp-log .ev .src.safety, .tp-log .ev .src.error { color: var(--red); border-color: rgba(239,68,68,0.45); }
.tp-log .ev.on > svg { color: var(--accent); }
.tp-log .ev.warning > svg { color: var(--amber); }
.tp-log .ev.error > svg { color: var(--red); }
.tp-log .ev .msg { font-family: 'JetBrains Mono', monospace; font-size: 0.76rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.tp .cmd-row { display: grid; grid-template-columns: 9rem 8rem minmax(0, 1fr) auto; gap: 0.75rem; font-size: 0.82rem; padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04); align-items: start; }
.tp .cmd-row .t { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; font-size: 0.76rem; }
.tp .cmd-row .st.done { color: var(--accent); }
.tp .cmd-row .st.error, .tp .cmd-row .st.expired { color: var(--red); }
.tp .cmd-row .st.pending, .tp .cmd-row .st.running { color: var(--amber); }
@media (max-width: 700px) { .tp .cmd-row { grid-template-columns: 1fr; gap: 0.2rem; } }

/* lightbox */
.tp-lightbox { flex-direction: row; gap: 0.5rem; padding: 1rem; }
.lb-figure { margin: 0; max-width: min(1500px, 92vw); display: flex; flex-direction: column; gap: 0.6rem; }
.lb-images { display: grid; grid-auto-flow: column; gap: 0.5rem; }
.lb-images img { max-width: 100%; max-height: 80vh; border-radius: 10px; object-fit: contain; background: #000; }
#lb-caption { color: var(--text-muted); font-size: 0.85rem; text-align: center; }
#lb-caption a { color: var(--blue); }
.lb-nav { position: static; flex-shrink: 0; }
.lb-close { position: absolute; top: 1rem; right: 1rem; }

/* no dashboard webcam: hide everything that's only about it */
.tp.no-dash [data-dash] { display: none !important; }
.tp.no-dash .tp-latest { grid-template-columns: minmax(0, 1fr); max-width: 900px; }
