/* ============================================================
   主控/设置/任务管理/解锁 共享样式(深色玻璃拟态,与线上视觉同源)
   ============================================================ */
:root {
    --active-color: #28a745;
    --idle-color: #6c757d;
    --fan-active-color: #17a2b8;
    --pump-active-color: #6f42c1;
    --switch-on-bg: #4cd964;
    --switch-off-bg: #e5e5ea;
    --water-high-color: #dc3545;
    --water-normal-color: #28a745;
    --water-low-color: #ffc107;
    --water-unknown-color: #6c757d;
    --temp-normal-color: #17a2b8;
    --temp-high-color: #dc3545;
    --humidity-normal-color: #6f42c1;
    --humidity-high-color: #fd7e14;
    --temp-water-normal: #17a2b8;
    --temp-water-high: #dc3545;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
    background-attachment: fixed;
    color: #fff;
    font-family: 'Segoe UI', 'Microsoft YaHei', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

a { text-decoration: none; }

/* ---------- 标题版本徽章 ---------- */
.version-badge {
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 2px 9px;
    border-radius: 50px;
    vertical-align: middle;
    margin-left: 6px;
    opacity: 0.85;
    letter-spacing: 0.5px;
}

/* ---------- 卡片 ---------- */
.card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    color: #fff;
}
.card-header {
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px 15px 0 0 !important;
    font-size: 1.05rem;
    padding: 12px 18px;
}
.card-header .btn { font-size: 0.85rem; }

/* ---------- 状态徽章 ---------- */
.status-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 18px 0 20px;
}
.status-badge {
    font-size: 1.15rem;
    padding: 10px 20px;
    border-radius: 50px;
    min-width: 170px;
    text-align: center;
    transition: all 0.3s;
}
.status-badge.active        { background-color: var(--active-color); }
.status-badge.idle          { background-color: var(--idle-color); }
.status-badge.fan-active    { background-color: var(--fan-active-color); }
.status-badge.fan-idle      { background-color: var(--idle-color); }
.status-badge.pump-active   { background-color: var(--pump-active-color); }
.status-badge.pump-idle     { background-color: var(--idle-color); }
.status-badge.plug-active   { background-color: #fd7e14; }
.status-badge.plug-idle     { background-color: var(--idle-color); }
.status-badge.water-pump-active { background-color: #20c997; }
.status-badge.water-pump-idle   { background-color: var(--idle-color); }
.status-badge.water-high    { background-color: var(--water-high-color); }
.status-badge.water-normal  { background-color: var(--water-normal-color); }
.status-badge.water-low     { background-color: var(--water-low-color); }
.status-badge.water-unknown { background-color: var(--water-unknown-color); }
.status-badge.temp-normal   { background-color: var(--temp-normal-color); }
.status-badge.temp-high     { background-color: var(--temp-high-color); }
.status-badge.humidity-normal { background-color: var(--humidity-normal-color); }
.status-badge.humidity-high { background-color: var(--humidity-high-color); }
.status-badge.temp-water-normal { background-color: var(--temp-water-normal); }
.status-badge.temp-water-high   { background-color: var(--temp-water-high); }

/* ---------- 设备开关组 ---------- */
.control-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}
.control-group {
    flex: 1;
    min-width: 160px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    text-align: center;
}
.control-group .status-badge { min-width: 0; font-size: 1.02rem; padding: 8px 12px; margin-bottom: 10px; }
.control-group .device-status { margin-top: 8px; font-size: 0.9rem; font-weight: 500; }
.control-group .status-on  { color: var(--active-color); }
.control-group .status-off { color: #ccc; }
@media (max-width: 992px) {
    .control-group { min-width: calc(50% - 10px); }
}

/* 手机端进一步收紧：徽章一行 2 个、开关组一行 2 个 */
@media (max-width: 576px) {
    .status-badge {
        min-width: calc(50% - 5px);
        font-size: 0.95rem;
        padding: 9px 8px;
    }
    .control-group { min-width: calc(50% - 8px); padding: 10px 6px; }
    .control-group .status-badge { font-size: 0.88rem; padding: 7px 6px; }
    .toolbar .btn-control { font-size: 0.92rem; padding: 8px 16px; }
    .stat-tile .value { font-size: 1.1rem; }
}

/* iOS 风格开关 */
.switch-container { display: flex; flex-direction: column; align-items: center; width: 100%; }
.switch-label { margin-bottom: 8px; font-size: 0.95rem; font-weight: 500; }
.ios-switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.ios-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--switch-off-bg); transition: .4s; border-radius: 34px;
}
.slider:before {
    position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px;
    background-color: #fff; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: var(--switch-on-bg); }
input:checked + .slider:before { transform: translateX(26px); }
#ledSwitch:checked + .slider { background-color: var(--active-color); }
#fanSwitch:checked + .slider { background-color: var(--fan-active-color); }
#pumpSwitch:checked + .slider { background-color: var(--pump-active-color); }
#waterPumpSwitch:checked + .slider { background-color: #20c997; }
#plugSwitch:checked + .slider { background-color: #fd7e14; }

/* ---------- 主控页按钮工具条（一排胶囊） ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 20px 0 6px;
}
.toolbar .btn-control {
    font-size: 1.02rem;
    padding: 9px 20px;
    border-radius: 50px;
    transition: transform 0.2s;
    white-space: nowrap;
}
.toolbar .btn-control:hover { transform: translateY(-2px); }
.toolbar-note { text-align: center; font-size: 0.88rem; color: rgba(255,255,255,0.75); margin: 8px 0 4px; }
.toolbar-note .feed-countdown { color: #4cd964; font-weight: 600; }

/* ---------- 系统信息 6 宫格 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.stat-tile {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    padding: 14px 6px 12px;
    text-align: center;
}
.stat-tile .icon { font-size: 1.05rem; opacity: 0.75; }
.stat-tile .value { font-size: 1.3rem; font-weight: 700; margin: 5px 0 2px; }
.stat-tile .label { font-size: 0.76rem; opacity: 0.65; }
@media (max-width: 768px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 九宫格解锁页 ---------- */
.lock-dots { display: flex; justify-content: center; gap: 18px; margin: 18px 0 24px; }
.lock-dots i {
    width: 13px; height: 13px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    display: block; transition: all 0.2s;
}
.lock-dots i.on {
    background: #4cd964; border-color: #4cd964;
    box-shadow: 0 0 10px rgba(76, 217, 100, 0.85);
}
.lock-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lock-cell {
    aspect-ratio: 1 / 1;
    font-size: 2.1rem; font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 14px; color: #fff;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.lock-cell:hover { background: rgba(255, 255, 255, 0.18); }
.lock-cell:active { transform: scale(0.94); }
.lock-cell.locked { pointer-events: none; opacity: 0.5; }
.lock-grid.shake { animation: lockShake 0.5s; }
@keyframes lockShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-9px); }
    40%, 80% { transform: translateX(9px); }
}
.lock-locked-msg { color: #ffc107; font-size: 0.95rem; margin-top: 14px; min-height: 1.2em; }

/* ---------- 任务管理页：投喂量/水泵时长选择 ---------- */
.portion-btn, .duration-btn { min-width: 60px; border-radius: 50px !important; }
.portion-btn.active {
    background-color: var(--active-color) !important;
    border-color: var(--active-color) !important;
    color: #fff;
}
.duration-btn.active {
    background-color: #20c997 !important;
    border-color: #20c997 !important;
    color: #fff;
}

/* 计划卡片 */
.schedule-item {
    background: rgba(0, 0, 0, 0.22);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.schedule-item .name { font-weight: 600; font-size: 1.02rem; }
.schedule-item .meta { font-size: 0.82rem; color: rgba(255,255,255,0.65); margin-top: 3px; }
.schedule-item .badge-time { font-size: 0.95rem; }
.schedule-item .op { color: rgba(255,255,255,0.55); font-size: 0.9rem; }
.schedule-item .op i { cursor: pointer; margin-left: 8px; }
.schedule-item .op i:hover { color: #fff; }

/* ---------- 日历 + 当日日志 ---------- */
.calendar-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.calendar-header .month-title { font-size: 1.08rem; font-weight: 600; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-grid .weekday { text-align: center; font-size: 0.78rem; opacity: 0.65; padding: 4px 0; }
.cal-day {
    position: relative;
    text-align: center; padding: 9px 0 7px;
    border-radius: 9px; cursor: pointer; font-size: 0.92rem;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.cal-day:hover { background: rgba(255, 255, 255, 0.12); }
.cal-day.today { outline: 1px solid rgba(255, 255, 255, 0.45); }
.cal-day.selected { background: var(--active-color); color: #fff; font-weight: 600; }
.cal-day .marks {
    display: flex; justify-content: center; align-items: center;
    gap: 2px; height: 8px; margin-top: 2px;
}
.cal-day .mark { width: 5px; height: 5px; border-radius: 50%; display: block; }
.mark-feed  { background: #ffc107; }
.mark-fan   { background: #17a2b8; }
.mark-pump  { background: #6f42c1; }
.mark-water { background: #20c997; }
.cal-day .mark-cloud {
    width: auto; height: auto; font-size: 7px; line-height: 8px;
    color: #ff4d6d; filter: drop-shadow(0 0 2px rgba(255, 77, 109, 0.9));
}

/* 日历图例 */
.cal-legend {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-top: 12px; font-size: 0.72rem; opacity: 0.75;
}
.cal-legend .item { display: flex; align-items: center; gap: 4px; }
.cal-legend .mark { width: 6px; height: 6px; }
.cal-legend .mark-cloud { font-size: 8px; line-height: 1; }

.day-title { font-size: 1.02rem; font-weight: 600; margin-bottom: 4px; }
.log-entry {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.95rem;
}
.log-entry:last-child { border-bottom: 0; }
.log-entry .time { color: rgba(255,255,255,0.6); min-width: 52px; font-variant-numeric: tabular-nums; }
.log-entry .type-icon { width: 26px; text-align: center; }
.log-entry .del {
    margin-left: auto; border: 0; background: none;
    color: rgba(255,255,255,0.45); cursor: pointer; font-size: 0.9rem;
}
.log-entry .del:hover { color: #dc3545; }

/* ---------- 设置页亮度 ---------- */
.brightness-box {
    width: 100%; height: 56px; border-radius: 10px;
    background: #b4a202;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: background 0.2s;
}

/* ---------- 模态框 ---------- */
.modal-content {
    background: #26263a;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
}
.modal-content .btn-close { filter: invert(1); }

/* ---------- 顶部 toast(单元素复用,连发不叠加) ---------- */
.main-toast {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
    z-index: 2000; padding: 10px 24px; border-radius: 50px;
    font-size: 0.95rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    max-width: 90%; text-align: center; pointer-events: none;
    transition: opacity 0.3s;
}
