/* ============================================
   SmartGarden Blazor App - ÀüÃ¼ ½ºÅ¸ÀÏ
   React ¡æ Blazor ¸¶ÀÌ±×·¹ÀÌ¼Ç
   ============================================ */

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background: #ffffff; color: #212529; }

/* ===== Layout ===== */
.layout-container { display: flex; min-height: 100vh; }

/* ===== Kiosk Mode (MainCtrl ÀüÃ¼È­¸é) ===== */
body.kiosk-mode .sidebar { display: none !important; }
body.kiosk-mode .layout-container { display: block; }

/* --- Sidebar --- */
.sidebar {
    width: 240px; flex-shrink: 0;
    background: #1e293b; color: #e2e8f0;
    display: flex; flex-direction: column;
    height: 100vh; position: sticky; top: 0;
}
.sidebar-header { padding: 1.2rem 1rem; border-bottom: 1px solid #334155; }
.sidebar-header h2 { font-size: 1.15rem; font-weight: 700; color: #e2e8f0; }
.sidebar-version { display: block; font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.sidebar-footer { padding: 0.8rem 1rem; border-top: 1px solid #334155; font-size: 0.75rem; color: #64748b; margin-top: auto; }

.nav-menu { list-style: none; padding: 0.75rem 0.5rem; flex: 1; overflow-y: auto; }
.nav-menu li { margin-bottom: 2px; }
.nav-menu a {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 0.8rem; border-radius: 6px;
    color: #94a3b8; text-decoration: none; font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
}
.nav-menu a:hover { background: rgba(59,130,246,0.08); color: #3b82f6; }
.nav-menu a.active { background: rgba(59,130,246,0.12); color: #3b82f6; font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

/* --- Main wrapper --- */
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* --- Top Bar --- */
.top-bar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1rem; height: 56px;
    background: #fff; border-bottom: 1px solid #e2e8f0;
}
.hamburger-btn {
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; padding: 0.3rem 0.5rem; border-radius: 6px;
    color: #1e293b;
}
.hamburger-btn:hover { background: rgba(30,41,59,0.08); }
.top-bar-title { font-size: 1.1rem; font-weight: 500; flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 0.3rem; }
.top-bar-actions .icon-btn {
    background: none; border: none; font-size: 1.2rem;
    cursor: pointer; padding: 0.35rem; border-radius: 50%;
    color: #64748b;
}
.top-bar-actions .icon-btn:hover { background: rgba(100,116,139,0.1); }

/* --- Main Content --- */
.main-content { flex: 1; padding: 1.5rem; overflow-y: auto; background: #e9edf3; }
h1 { margin-bottom: 1rem; color: #1e293b; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.375rem 0.75rem; border: 1px solid transparent; border-radius: 0.375rem;
    font-size: 0.9rem; font-weight: 500; cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: #0d6efd; color: #fff; }
.btn-success { background: #198754; color: #fff; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-info { background: #0dcaf0; color: #000; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Form Elements ===== */
.form-input, .form-select {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #d1d5db;
    border-radius: 0.375rem; font-size: 0.9rem; background: #fff;
    transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; font-weight: 500; color: #475569; }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 0.75rem; }
.form-grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 0.75rem; }
.form-group-action { display: flex; align-items: flex-end; }
.form-group-check { display: flex; align-items: center; padding-top: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.9rem; }
.radio-label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; margin-bottom: 0.3rem; }
.radio-group { margin-bottom: 1rem; }
.radio-group > label:first-child { font-weight: 500; margin-bottom: 0.4rem; display: block; }
.hint-text { font-size: 0.78rem; color: #94a3b8; margin-top: 0.2rem; }
.hint-inline { font-size: 0.78rem; color: #94a3b8; margin-left: 0.5rem; }

/* ===== Form Cards ===== */
.form-card { background: #fff; border-radius: 0.375rem; padding: 1rem; margin-bottom: 1rem; border: 1px solid #dee2e6; box-shadow: 0 .125rem .25rem rgba(0,0,0,.075); }
.form-card-header { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1.05rem; margin-bottom: 1.2rem; color: #1e293b; flex-wrap: wrap; }
.badge-required { background: #fbbf24; color: #78350f; font-size: 0.72rem; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ===== Condition Rows ===== */
.condition-header { display: flex; align-items: center; justify-content: space-between; margin: 0.75rem 0 0.5rem; }
.condition-title { font-weight: 600; font-size: 0.9rem; color: #1e293b; }
.condition-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 0.5rem; align-items: end; margin-bottom: 0.5rem; padding: 0.5rem; background: #f9fafb; border-radius: 6px; }
.form-group-del { display: flex; align-items: flex-end; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box { background: #fff; border-radius: 12px; width: 90%; max-width: 600px; max-height: 80vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid #e5e7eb; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b; }
.modal-body { padding: 1rem 1.2rem; overflow-y: auto; flex: 1; }
.modal-content { font-size: 0.85rem; white-space: pre-wrap; word-break: break-all; margin: 0; }
.modal-footer { padding: 0.75rem 1.2rem; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; }
.modal-info-row { margin-bottom: 0.4rem; font-size: 0.95rem; }
.modal-info-row a { color: #2563eb; text-decoration: underline; }

/* ===== Toggle Switch ===== */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #cbd5e1; border-radius: 24px; transition: 0.3s;
}
.toggle-switch .slider::before {
    content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .slider { background: #3b82f6; }
.toggle-switch input:checked + .slider::before { transform: translateX(20px); }
.toggle-switch.disabled .slider { opacity: 0.5; cursor: not-allowed; }
.toggle-switch .slider.auto-color { background: #f59e0b; }
.toggle-switch input:checked + .slider.auto-color { background: #f59e0b; }

/* =========================================
   Pages: Statusboard (Home)
   ========================================= */
.statusboard-root { min-height: 100%; }
.statusboard-title { font-size: 1.5rem; font-weight: 500; color: #212529; margin-bottom: 1rem; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    --stat-accent: #0d6efd;
    border-radius: 0.375rem;
    padding: 1rem;
    color: #212529;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.25rem;
    min-height: 112px;
    background: #f3f5f8;
    border: 1px solid #cfd6df;
    border-left: 0.25rem solid var(--stat-accent);
    box-shadow: 0 .125rem .25rem rgba(0,0,0,.075);
}
.stat-label { font-size: 0.875rem; font-weight: 500; color: #5b6472; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: #1f2937; }
.stat-purple { --stat-accent: #0d6efd; }
.stat-green { --stat-accent: #198754; }
.stat-blue { --stat-accent: #0dcaf0; }
.stat-teal { --stat-accent: #6c757d; }

.statusboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }

.history-panel, .alarm-panel {
    background: #f1f4f8; border-radius: 0.375rem; padding: 1rem; border: 1px solid #cfd6df; box-shadow: 0 .125rem .25rem rgba(0,0,0,.08);
}
.panel-title { font-size: 1.05rem; font-weight: 600; color: #1f2937; margin-bottom: 0.75rem; }

.log-list { max-height: 400px; overflow-y: auto; }
.log-entry { margin-bottom: 0.4rem; font-size: 0.9rem; }
.log-time { color: #1f2937; font-weight: 500; margin-right: 1rem; }
.log-msg { color: #4b5563; }

.alarm-card { border-radius: 8px; padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; font-size: 0.87rem; }
.alarm-license { background: #edf4ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.alarm-interval { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.alarm-water { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.alarm-time { background: #ecfeff; color: #155e75; border: 1px solid #bae6fd; }

/* =========================================
   Pages: MainCtrl
   ========================================= */
.mainctrl-root { min-height: 100vh; transition: background 0.3s, color 0.3s; }
.mainctrl-root.dark { background: #0f172a; color: #e2e8f0; }
.mainctrl-root.light { background: #f8fafc; color: #1e293b; }

.mainctrl-card { max-width: 1400px; margin: 0 auto; padding: 1rem; }

.mainctrl-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem;
    padding: 0.6rem 1rem; border-radius: 10px;
    margin-bottom: 1rem;
}
.mainctrl-root.dark .mainctrl-header { background: #1e293b; }
.mainctrl-root.light .mainctrl-header { background: #fff; border: 1px solid #e2e8f0; }

.header-left { display: flex; align-items: center; gap: 0.75rem; }
.home-btn { text-decoration: none; font-size: 1.3rem; }
.site-title { font-weight: 700; font-size: 1.1rem; }
.current-time { font-size: 0.9rem; opacity: 0.7; }
.header-center { display: flex; gap: 1rem; font-size: 0.9rem; }
.header-right { display: flex; align-items: center; gap: 0.5rem; }
.mode-label { font-size: 0.85rem; }
.mode-text { font-size: 0.85rem; font-weight: 600; }
.mode-text.auto { color: #f59e0b; }
.mode-text.manual { color: #3b82f6; }
.divider-v { width: 1px; height: 20px; background: #94a3b8; opacity: 0.4; margin: 0 0.25rem; }
.icon-btn { background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 0.3rem; border-radius: 6px; }
.mainctrl-root.dark .icon-btn { color: #e2e8f0; }
.mainctrl-root.light .icon-btn { color: #1e293b; }

.section { margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }

.sensor-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 1rem; }
.actuator-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 0.75rem; }

/* ¦¡¦¡ ¼¾¼­ Ä«µå: Å©°í ÀÐ±â ÁÁ°Ô, ³»¿ë Áß¾Ó ¹èÄ¡ ¦¡¦¡ */
.sensor-card {
    border-radius: 12px;
    padding: 2rem 2.5rem;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.sensor-card.dark  { background: #1e293b; }
.sensor-card.light { background: #fff; border: 1px solid #e5e7eb; }

.sensor-header {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 1.2rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid rgba(128,128,128,0.2);
}
.sensor-row   { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 0; gap: 0.5rem; }
.sensor-label { font-size: 1.2rem; opacity: 0.7; }
.sensor-value { font-weight: 700; font-size: 2.4rem; letter-spacing: -0.5px; }

/* ¦¡¦¡ ¾×Ãß¿¡ÀÌÅÍ Ä«µå: ÄÜÅÙÃ÷ ³ôÀÌ¿¡ ¸Â°Ô, ÇÏ´Ü °ø¹é ÃÖ¼ÒÈ­ ¦¡¦¡ */
.actuator-card {
    border-radius: 10px;
    padding: 0.75rem 1rem 0.5rem 1rem;
    align-self: start;
}
.actuator-card.dark  { background: #1e293b; }
.actuator-card.light { background: #fff; border: 1px solid #e5e7eb; }

.actuator-header { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.4rem; padding-bottom: 0.35rem; border-bottom: 1px solid rgba(128,128,128,0.2); }
.actuator-row { display: flex; align-items: center; flex-wrap: wrap; padding: 0.25rem 0; gap: 0.4rem; }
.actuator-row > span:first-child { flex: 1; min-width: 50px; font-size: 0.88rem; }
.state-text { font-size: 0.8rem; min-width: 28px; text-align: center; }

.three-state-btns { display: flex; gap: 0.3rem; }
.three-btn {
    padding: 0.25rem 0.6rem; border: 1px solid #94a3b8; border-radius: 6px;
    background: transparent; cursor: pointer; font-size: 0.8rem; color: inherit;
    transition: background 0.15s;
}
.three-btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.three-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================================
   Pages: Schedule
   ========================================= */
.schedule-root { min-height: 100%; }
.schedule-layout { display: flex; min-height: calc(100vh - 120px); }

.schedule-sidebar {
    width: 300px; flex-shrink: 0;
    background: #dfe5ed;
    border-right: 1px solid #c4ccd6;
    padding: 1.5rem; display: flex; flex-direction: column;
}
.sidebar-list-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.75rem; text-align: center; color: #1f2937; }
.region-filter { margin-bottom: 1rem; }
.region-filter label { font-size: 0.85rem; font-weight: 500; display: block; margin-bottom: 0.3rem; color: #475569; }

.schedule-list {
    flex: 1; overflow-y: auto; margin-bottom: 0.75rem;
    padding-right: 0.25rem;
}
.schedule-list::-webkit-scrollbar { width: 8px; }
.schedule-list::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.schedule-list::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
.schedule-list::-webkit-scrollbar-thumb:hover { background: #555; }
.schedule-item {
    padding: 0.65rem 0.85rem; border-radius: 6px; cursor: pointer;
    margin-bottom: 0.35rem; background: #eef2f6; color: #1f2937; border: 1px solid #cfd6df;
    transition: background 0.15s, color 0.15s;
}
.schedule-item:hover { background: #e2e8ef; }
.schedule-item.active { background: #0d6efd; color: #fff; border-color: #0d6efd; }
.schedule-item.active:hover { background: #0b5ed7; }
.schedule-item.active .schedule-item-info { color: rgba(255,255,255,0.85); }
.schedule-item-name { font-weight: 700; font-size: 0.92rem; margin-bottom: 0.15rem; }
.schedule-item-info { font-size: 0.8rem; color: #64748b; line-height: 1.45; }

.sidebar-actions { margin-top: auto; padding-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar-actions .btn { width: 100%; padding: 0.75rem; font-size: 0.95rem; }

.schedule-main { flex: 1; min-width: 0; background: #e6ebf2; padding: 2rem; color: #1f2937; }
.schedule-main-title { font-size: 1.8rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; color: #1f2937; }
.schedule-sub { font-size: 0.9rem; color: #64748b; margin-bottom: 2rem; text-align: center; }

/* =========================================
   Pages: SensingChart
   ========================================= */
.sensingchart-root { min-height: 100%; }
.chart-panel { background: #eef2f7; border-radius: 0.375rem; padding: 1rem; border: 1px solid #cfd6df; box-shadow: 0 .125rem .25rem rgba(0,0,0,.08); color: #1f2937; }
.chart-title { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 1rem; color: #1f2937; }

.chart-query-bar { margin-bottom: 1.5rem; }
.chart-message { font-size: 0.95rem; color: #64748b; margin-bottom: 0.75rem; }
.date-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.date-row label { font-size: 0.9rem; font-weight: 500; color: #475569; }
.date-row .form-input { width: auto; min-width: 160px; }

.chart-section { margin-bottom: 2rem; }
.chart-section-title { font-size: 1.1rem; font-weight: 600; text-align: center; margin-bottom: 1rem; color: #1f2937; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); gap: 1rem; }
.chart-placeholder {
    border: 1px solid #cfd6df; border-radius: 0.375rem;
    padding: 0.75rem; background: #e9eef4;
}
.chart-label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; text-align: center; color: #334155; }
.chart-canvas-wrap { position: relative; width: 100%; height: 220px; }
.chart-canvas-wrap canvas { position: absolute; inset: 0; }

/* =========================================
   Pages: Settings
   ========================================= */
.settings-root { max-width: 900px; margin: 0 auto; background: #e7ecf3; padding: 1rem; border-radius: 0.375rem; border: 1px solid #cfd6df; }
.settings-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 1.5rem; color: #1f2937; }
.settings-card {
    background: #eff3f7; border-radius: 0.375rem; padding: 1rem;
    margin-bottom: 1rem; border: 1px solid #cfd6df; box-shadow: 0 .125rem .25rem rgba(0,0,0,.08); color: #1f2937;
}
.settings-card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 1rem; color: #1f2937; }
.settings-section-toggle { margin-bottom: 0.75rem; }

.schedule-root .form-input,
.schedule-root .form-select,
.sensingchart-root .form-input,
.sensingchart-root .form-select,
.settings-root .form-input,
.settings-root .form-select {
    background: #ffffff;
    color: #1f2937;
    border-color: #cbd5e1;
}

.schedule-root .form-input:focus,
.schedule-root .form-select:focus,
.sensingchart-root .form-input:focus,
.sensingchart-root .form-select:focus,
.settings-root .form-input:focus,
.settings-root .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.25);
}

.doc-icons-row { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.doc-icon-btn {
    background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px;
    width: 48px; height: 48px; font-size: 1.5rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.doc-icon-btn:hover { background: #e2e8f0; }

/* =========================================
   Pages: Auth
   ========================================= */
.auth-layout {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: #f8fafc; padding: 2rem;
}
.signin-box {
    width: 100%; max-width: 400px;
    background: #fff; padding: 2rem; border-radius: 12px;
    border: 1px solid #e5e7eb; box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.signin-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; text-align: center; }
.signin-error { background: #fef2f2; color: #dc2626; padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.85rem; margin: 0.75rem 0; }
.signin-btn { width: 100%; margin-top: 1rem; padding: 0.7rem; font-size: 1rem; }
.signin-pwa-wrap { display: flex; justify-content: center; margin-bottom: 0.9rem; }
.signin-pwa-btn { min-width: 170px; }
.signin-pwa-hint { text-align: center; margin-bottom: 0.9rem; }

.keypad { margin: 1rem 0; }
.keypad-row { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 0.5rem; }
.keypad-btn {
    width: 52px; height: 48px; border: 1px solid #d1d5db; border-radius: 8px;
    background: #fff; font-size: 1.1rem; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
}
.keypad-btn:hover { background: #f1f5f9; }
.keypad-btn:active { background: #e2e8f0; }
.keypad-del { color: #ef4444; }
.keypad-clear { color: #64748b; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .statusboard-grid { grid-template-columns: 1fr; }
    .schedule-layout { flex-direction: column; }
    .schedule-sidebar { width: 100%; }
    .condition-row { grid-template-columns: 1fr 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .sensor-grid, .actuator-grid { grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); }
}
