/* ============================================================
   Cultivee — Design System
   ============================================================ */

:root {
    --primary: hsl(142 71% 45%); --primary-light: hsl(142 71% 55%);
    --primary-dark: hsl(142 71% 30%); --primary-bg: hsl(142 50% 96%);
    --bg: hsl(142 20% 97%); --bg-card: #fff; --bg-elevated: hsl(0 0% 98%);
    --text: hsl(220 13% 12%); --text-secondary: hsl(220 9% 46%); --text-muted: hsl(220 13% 65%);
    --border: hsl(220 13% 91%);
    --gradient-primary: linear-gradient(135deg, hsl(142 71% 45%), hsl(142 71% 55%));
    --gradient-hero: linear-gradient(135deg, hsl(142 71% 45%), hsl(170 60% 40%));
    --gradient-navbar: linear-gradient(135deg, hsl(220 15% 7%), hsl(220 15% 12%));
    --shadow-card: 0 4px 16px hsl(0 0% 0% / 0.06), 0 1px 3px hsl(0 0% 0% / 0.04);
    --shadow-elevated: 0 10px 30px hsl(0 0% 0% / 0.08);
    --radius: 0.75rem; --radius-lg: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }

/* --- Auth Screen ------------------------------------------------- */
.screen { min-height: 100vh; }
#auth-screen { display: flex; justify-content: center; align-items: center; background: var(--gradient-navbar); }
.auth-card { background: #fff; border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 380px; margin: 1rem; box-shadow: var(--shadow-elevated); }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo h1 { color: var(--primary); font-size: 2rem; }
.auth-logo p { color: var(--text-muted); font-size: 0.85rem; }
.auth-card input { width: 100%; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.95rem; margin-bottom: 0.75rem; }
.auth-card input:focus { outline: none; border-color: var(--primary); }
.auth-card button { width: 100%; padding: 0.85rem; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer; }
.auth-card button:hover { background: var(--primary-dark); }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.8rem; color: var(--text-muted); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-error { background: hsl(0 80% 97%); color: hsl(0 63% 51%); border: 1px solid hsl(0 63% 85%); padding: 0.5rem; border-radius: var(--radius); text-align: center; font-size: 0.8rem; margin-top: 0.75rem; }

/* --- Navbar ------------------------------------------------------ */
.navbar { background: var(--gradient-navbar); padding: 0 2rem; position: sticky; top: 0; z-index: 50; border-bottom: 1px solid hsl(142 71% 45% / 0.2); }
.navbar-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; height: 3.5rem; }
.logo { display: flex; align-items: center; gap: 0.6rem; }
.logo-icon { width: 2rem; height: 2rem; background: var(--gradient-primary); border-radius: 0.5rem; display: flex; align-items: center; justify-content: center; color: white; box-shadow: 0 0 12px hsl(142 71% 55% / 0.4); }
.logo-text { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.04em; background: var(--gradient-hero); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.nav-status { display: flex; align-items: center; gap: 0.75rem; }
.status-divider { width: 1px; height: 1rem; background: hsl(0 0% 100% / 0.12); }

/* --- Main -------------------------------------------------------- */
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* --- Cards ------------------------------------------------------- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--bg-elevated); }
.card-title { display: flex; align-items: center; gap: 0.5rem; }
.card-title svg { color: var(--primary); }
.card-title h2 { font-size: 0.85rem; font-weight: 600; }

/* --- Modules ----------------------------------------------------- */
.btn-add { padding: 0.35rem 0.75rem; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.btn-add:hover { background: var(--primary-dark); }

.modules-list { padding: 0.75rem; }
.module-item { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; background: var(--bg-elevated); border-radius: var(--radius); margin-bottom: 0.5rem; border: 1px solid var(--border); }
.module-info { display: flex; align-items: center; gap: 0.75rem; }
.module-icon { font-size: 1.5rem; }
.module-name { font-weight: 600; font-size: 0.9rem; }
.module-meta { font-size: 0.7rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; }

.module-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.gpio-btn { padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-size: 0.7rem; font-weight: 600; cursor: pointer; transition: var(--transition); }
.gpio-btn.on { background: var(--primary-bg); border-color: var(--primary); color: var(--primary-dark); }
.gpio-btn:hover { border-color: var(--primary); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--primary-light); box-shadow: 0 0 8px hsl(142 71% 55% / 0.6); animation: pulse-dot 2s ease-in-out infinite; }
.status-dot.offline { background: hsl(0 63% 51%); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* --- Live Badge / Stream ----------------------------------------- */
.live-badge { display: flex; align-items: center; gap: 0.4rem; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; color: hsl(0 0% 60%); padding: 0.25rem 0.65rem; border-radius: 999px; background: hsl(0 0% 95%); border: 1px solid var(--border); }
.live-badge.active { color: hsl(0 63% 51%); background: hsl(0 80% 97%); border-color: hsl(0 63% 85%); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: hsl(0 0% 70%); }
.live-badge.active .live-dot { background: hsl(0 63% 51%); animation: pulse-dot 1.5s ease-in-out infinite; }

.stream-wrapper { position: relative; background: transparent; display: flex; justify-content: center; align-items: center; }
.stream-wrapper img { width: 50%; height: auto; display: block; object-fit: contain; margin: 0 auto; }
.stream-wrapper img.hidden { display: none; }
.stream-offline { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; color: hsl(0 0% 40%); min-height: 200px; }
.stream-offline svg { opacity: 0.3; }
.stream-offline p { font-size: 0.8rem; opacity: 0.5; }
.stream-offline.hidden { display: none; }

/* --- Carousel ---------------------------------------------------- */
.carousel-controls { display: flex; align-items: center; gap: 0.5rem; }
.carousel-counter { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; min-width: 2rem; text-align: center; }
.btn-icon { width: 1.75rem; height: 1.75rem; border-radius: 50%; background: transparent; border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: var(--transition); }
.btn-icon:hover { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.carousel-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; padding: 1rem 1.25rem; }
.carousel-item { position: relative; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden; cursor: pointer; border: 2px solid transparent; transition: var(--transition); background: hsl(220 15% 95%); }
.carousel-item:hover { border-color: var(--primary); transform: translateY(-3px); }
.carousel-item img { width: 100%; height: 100%; object-fit: cover; }
.carousel-item .capture-info { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, hsl(0 0% 0% / 0.75)); padding: 1.5rem 0.6rem 0.5rem; font-size: 0.65rem; color: hsl(0 0% 85%); text-align: center; font-weight: 500; }
.capture-info .capture-size { color: var(--primary-light); }

/* --- Empty State ------------------------------------------------- */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 2rem; color: var(--text-muted); }
.empty-state p { font-size: 0.8rem; }

/* --- Modal ------------------------------------------------------- */
.modal { position: fixed; inset: 0; background: hsl(0 0% 0% / 0.88); z-index: 100; display: flex; justify-content: center; align-items: center; padding: 2rem; backdrop-filter: blur(12px); }
.modal-content { position: relative; max-width: 95vw; max-height: 95vh; }
.modal-content img { max-width: 100%; max-height: 85vh; border-radius: var(--radius); box-shadow: 0 20px 60px hsl(0 0% 0% / 0.5); }
.modal-info { text-align: center; padding: 0.75rem; font-size: 0.8rem; color: hsl(0 0% 65%); }
.modal-close { position: absolute; top: -0.5rem; right: -0.5rem; background: hsl(0 63% 51%) !important; border: none !important; color: #fff !important; width: 2rem; height: 2rem; border-radius: 50%; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* --- Wizard Modal ------------------------------------------------ */
.wizard-modal { background: #fff; border-radius: var(--radius-lg); padding: 2rem; max-width: 440px; width: 100%; }
.wizard-step { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.wizard-header { text-align: center; margin-bottom: 1.25rem; }
.wizard-header h3 { font-size: 1.15rem; margin-top: 0.75rem; }
.wizard-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.35rem; }

.wizard-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto; background: var(--primary-bg); color: var(--primary); }
.wifi-icon { background: hsl(210 80% 95%); color: hsl(210 80% 50%); }
.settings-icon { background: hsl(35 80% 95%); color: hsl(35 80% 45%); }
.success-icon { background: hsl(142 50% 93%); color: var(--primary); }
.link-icon { background: hsl(270 60% 95%); color: hsl(270 60% 50%); }

/* Progress */
.wizard-progress { margin-bottom: 1.25rem; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gradient-primary); border-radius: 2px; transition: width 0.4s ease; }
.progress-text { display: block; text-align: center; font-size: 0.7rem; color: var(--text-muted); margin-top: 0.35rem; }

/* WiFi card */
.wifi-card { background: hsl(210 30% 97%); border: 1px solid hsl(210 30% 90%); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.wifi-info { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.wifi-label { font-size: 0.75rem; color: var(--text-muted); min-width: 3rem; }
.wifi-value { font-size: 0.95rem; font-weight: 600; font-family: monospace; letter-spacing: 0.02em; }
.reconnect-card { background: hsl(142 30% 97%); border-color: hsl(142 30% 88%); }

/* URL card */
.url-card { background: hsl(220 15% 10%); color: #fff; border-radius: var(--radius); padding: 0.85rem 1rem; display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; cursor: pointer; transition: var(--transition); }
.url-card:hover { background: hsl(220 15% 15%); }
.url-text { font-family: monospace; font-size: 1rem; font-weight: 600; }
.url-copy { font-size: 0.7rem; color: var(--primary-light); font-weight: 600; }

/* Checklist */
.wizard-checklist { margin-bottom: 1.25rem; }
.check-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; font-size: 0.85rem; color: var(--text-secondary); }
.check-num { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.wizard-note { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-bottom: 1rem; padding: 0.5rem; background: hsl(45 80% 96%); border-radius: var(--radius); border: 1px solid hsl(45 60% 88%); }

/* Wizard actions */
.wizard-actions { display: flex; gap: 0.75rem; }
.btn-primary { flex: 1; padding: 0.75rem; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-weight: 600; cursor: pointer; font-size: 0.9rem; transition: var(--transition); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { padding: 0.75rem 1.25rem; background: transparent; color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius); font-weight: 500; cursor: pointer; font-size: 0.9rem; transition: var(--transition); }
.btn-secondary:hover { border-color: var(--text-muted); }

/* Wizard options */
.wizard-options { display: flex; flex-direction: column; gap: 0.75rem; }
.wizard-option { display: flex; align-items: center; gap: 1rem; padding: 1rem; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; text-align: left; transition: var(--transition); }
.wizard-option:hover { border-color: var(--primary); background: var(--primary-bg); }
.wizard-option strong { display: block; font-size: 0.9rem; }
.wizard-option small { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.wizard-option-icon { width: 40px; height: 40px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0; }

/* Wizard inputs */
.wizard-modal input { width: 100%; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; margin-bottom: 0.75rem; }
.wizard-modal input:focus { outline: none; border-color: var(--primary); }

/* --- Footer ------------------------------------------------------ */
.footer { text-align: center; padding: 1.25rem; font-size: 0.7rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 1rem; }

/* --- Responsive -------------------------------------------------- */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .navbar-inner { height: auto; padding: 0.75rem 0; }
    main { padding: 1rem; }
    .carousel-track { grid-template-columns: repeat(2, 1fr); padding: 0.75rem; }
    .stream-wrapper img { width: 100%; }
}
