/* ── AHU Unit Dashboard ───────────────────────────────────── */

.ahu-dashboard {
    padding: 16px;
    width: 100%;
}
@media (max-width: 639px) {
    .ahu-dashboard {
        padding: 0;
    }
    .ahu-card {
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid #ddd;
    }
}

.ahu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* ── Card ── */
.ahu-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.ahu-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

.ahu-card-header {
    background: #26a69a;
    color: #fff;
    padding: 14px 16px 12px;
}
.ahu-card-title {
    font-size: 1.05em;
    font-weight: 700;
    margin-bottom: 2px;
}
.ahu-card-desc {
    font-size: 0.82em;
    opacity: 0.88;
}

.ahu-card-status {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
    background: #f7f7f7;
    font-size: 0.83em;
    color: #444;
    line-height: 1.6;
}
.ahu-status-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ahu-card-commands {
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    flex: 1;
    align-content: flex-start;
}
.ahu-no-commands {
    font-size: 0.82em;
    color: #888;
    align-self: center;
}

.ahu-cmd-btn {
    background: #e0f2f1;
    border: 1px solid #26a69a;
    color: #30746e;
    border-radius: 4px;
    padding: 5px 11px;
    cursor: pointer;
    font-size: 0.83em;
    font-weight: 600;
    transition: background 0.12s, color 0.12s;
    line-height: 1.4;
}
.ahu-cmd-btn:hover {
    background: #26a69a;
    color: #fff;
}
.ahu-cmd-btn:active {
    background: #30746e;
    color: #fff;
}

.ahu-card-footer {
    padding: 9px 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.ahu-manage-btn {
    background: none;
    border: 1px solid #26a69a;
    color: #26a69a;
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
}
.ahu-manage-btn:hover {
    background: #26a69a;
    color: #fff;
}
.ahu-manage-btn-primary {
    background: #26a69a;
    border: 1px solid #26a69a;
    color: #fff;
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.12s;
}
.ahu-manage-btn-primary:hover { background: #30746e; border-color: #30746e; }
.ahu-manage-btn-danger {
    background: none;
    border: 1px solid #c00;
    color: #c00;
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
}
.ahu-manage-btn-danger:hover { background: #c00; color: #fff; }

/* Equal-width footer buttons on schedule cards */
.ahu-sched-grid .ahu-card-footer button { flex: 1; text-align: center; }

/* Schedule card grid — single wide column on desktop, standard grid on mobile */
.ahu-sched-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 640px) {
    .ahu-sched-grid {
        grid-template-columns: 1fr;
    }
    .ahu-sched-grid .ahu-card {
        flex-direction: row;
        min-height: 0;
    }
    .ahu-sched-grid .ahu-card-header {
        min-width: 160px;
        max-width: 180px;
        border-radius: 8px 0 0 8px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .ahu-sched-grid .ahu-card-status {
        flex: 1;
        border-bottom: none;
        border-right: 1px solid #eee;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        padding: 10px 16px;
    }
    .ahu-sched-grid .ahu-card-footer {
        border-top: none;
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        min-width: 100px;
    }
    .ahu-sched-grid .ahu-card-footer button {
        width: 100%;
        text-align: center;
    }
}

.ahu-sched-label {
    display: inline-block;
    width: 90px;
    font-weight: 600;
    color: #666;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.ahu-sched-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 1em;
    color: #333;
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Empty state ── */
.ahu-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}
.ahu-empty-state h3 { font-size: 1.2em; margin-bottom: 10px; color: #333; }
.ahu-empty-state p  { font-size: 0.9em; line-height: 1.7; }

/* ── Unit Manage page ── */
.ahu-manage-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.ahu-back-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #555;
    padding: 5px 12px;
    font-size: 0.85em;
    cursor: pointer;
    margin-bottom: 14px;
    display: inline-block;
}
.ahu-back-btn:hover { background: #f0f0f0; }

.ahu-last-cmd {
    font-size: 0.85em;
    color: #444;
    background: #f0faf5;
    border-left: 3px solid #26a69a;
    padding: 7px 12px;
    border-radius: 0 4px 4px 0;
    margin-bottom: 14px;
}

.ahu-cmd-group {
    margin-bottom: 14px;
}
.ahu-cmd-group-label {
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    margin-bottom: 7px;
}
.ahu-cmd-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ahu-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: 700;
}
.ahu-badge-active   { background: #e0f2f1; color: #26a69a; }
.ahu-badge-disabled { background: #fdecea; color: #c00; }

/* ── Last-seen dot badge ── */
@keyframes ahu-pulse {
    0%   { box-shadow: 0 0 3px 1px rgba(0, 230, 118, 0.6), 0 0 0 0   rgba(0, 230, 118, 0.7); }
    70%  { box-shadow: 0 0 3px 1px rgba(0, 230, 118, 0.6), 0 0 0 5px rgba(0, 230, 118, 0);   }
    100% { box-shadow: 0 0 3px 1px rgba(0, 230, 118, 0.6), 0 0 0 0   rgba(0, 230, 118, 0);   }
}
.ahu-dot-pulse { animation: ahu-pulse 2.5s ease-out infinite; }
.ahu-lastseen-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.18);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.78em;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

/* ── Control Systems Hub ── */
.ahu-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px;
}
@media (max-width: 600px) {
    .ahu-hub-grid { grid-template-columns: 1fr; padding: 8px; }
}

.ahu-hub-card-body {
    flex: 1;
}
.ahu-hub-desc {
    color: #666;
    font-size: 0.85em;
    margin-bottom: 12px;
    line-height: 1.4;
}
.ahu-hub-stat-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}
.ahu-hub-stat-block {
    display: flex;
    flex-direction: column;
    line-height: 1;
}
.ahu-hub-stat-num {
    font-size: 2em;
    font-weight: 700;
    color: #26a69a;
}
.ahu-hub-stat-label {
    font-size: 0.72em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}
.ahu-hub-stat-dim .ahu-hub-stat-num { color: #bbb; }

.ahu-hub-btn-row {
    display: flex;
    gap: 0;
    padding: 8px 12px;
}
.ahu-hub-btn-row-sep {
    border-top: 1px solid #f0f0f0;
    padding-top: 7px;
}
.ahu-hub-action-btn {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fafafa;
    color: #444;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 600;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    margin: 0 3px;
    white-space: nowrap;
}
.ahu-hub-action-btn:first-child { margin-left: 0; }
.ahu-hub-action-btn:last-child  { margin-right: 0; }
.ahu-hub-action-btn:hover {
    background: #26a69a;
    border-color: #26a69a;
    color: #fff;
}
.ahu-hub-action-btn-primary {
    background: #26a69a;
    border-color: #26a69a;
    color: #fff;
}
.ahu-hub-action-btn-primary:hover {
    background: #1e8a7e;
    border-color: #1e8a7e;
}
.ahu-hub-action-btn-warn {
    border-color: #e65100;
    color: #e65100;
}
.ahu-hub-action-btn-warn:hover {
    background: #e65100;
    border-color: #e65100;
    color: #fff;
}
.ahu-hub-action-btn-subtle {
    border-color: #ddd;
    color: #777;
}
.ahu-hub-action-btn-subtle:hover {
    background: #555;
    border-color: #555;
    color: #fff;
}

/* ── Schedule calendar ── */
.ahu-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
    flex-wrap: wrap;
}
.ahu-cal-week-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    flex: 1;
    text-align: center;
}
.ahu-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}
.ahu-cal-day {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    min-height: 100px;
    background: #fff;
}
.ahu-cal-today {
    border-color: #26a69a;
}
.ahu-cal-day-header {
    background: #eceff1;
    padding: 5px 6px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}
.ahu-cal-today .ahu-cal-day-header {
    background: #26a69a;
    color: #fff;
}
.ahu-cal-day-name {
    font-weight: 700;
    font-size: 0.78rem;
    display: block;
}
.ahu-cal-day-date {
    font-size: 0.72rem;
    opacity: 0.75;
    display: block;
}
.ahu-cal-day-body {
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ahu-cal-event {
    background: #e3f2fd;
    border-left: 3px solid #1976d2;
    border-radius: 3px;
    padding: 4px 5px;
    cursor: pointer;
    transition: background 0.15s;
}
.ahu-cal-event:hover {
    background: #bbdefb;
}
.ahu-cal-event-disabled {
    background: #f5f5f5;
    border-left-color: #bbb;
    opacity: 0.6;
}
.ahu-cal-event-time {
    font-size: 0.68rem;
    color: #555;
    font-weight: 700;
}
.ahu-cal-event-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1a237e;
    line-height: 1.2;
}
.ahu-cal-event-cmd {
    font-size: 0.68rem;
    color: #666;
}
@media (max-width: 800px) {
    .ahu-cal-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 500px) {
    .ahu-cal-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Schedule override banner ── */
.ahu-override-banner {
    background: #fff3e0;
    border: 1px solid #ff9800;
    border-radius: 6px;
    padding: 10px 14px;
    color: #e65100;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.ahu-override-cancel-btn {
    background: #e65100;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.ahu-override-cancel-btn:hover {
    background: #bf360c;
}
