/* ═══ CONVERTED TO LIGHT WARM THEME + 1.2x FONTS ═══ */
/* ═══════════════════════════════════════════════════════════
   Ezibee AI Energy — Styles (dark theme, match EMS)
   ═══════════════════════════════════════════════════════════ */

.glass {
    background: linear-gradient(180deg,#fffefa,rgba(8,14,31,.95));
    border: 1px solid rgba(0,0,0,.06);
}

/* ── Topbar ── */
.ai-topbar {
    border-radius: 14px;
    padding: 14px 22px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.ai-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-logo {
    font-size: 31.2px;
}

.ai-title {
    font-size: 20.4px;
    font-weight: 800;
    color: #2d2d42;
}

.ai-subtitle {
    font-size: 13.2px;
    color: #9e9eb0;
}

    .ai-subtitle .dot {
        color: #3b82f6;
        margin: 0 5px;
    }

.ai-tabs {
    display: flex;
    gap: 3px;
}

.ai-tab {
    padding: 7px 16px;
    border-radius: 7px;
    font-size: 14.4px;
    font-weight: 600;
    color: #9e9eb0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: .2s;
}

    .ai-tab:hover {
        background: rgba(0,0,0,.03);
        color: #2d2d42;
    }

    .ai-tab.active {
        background: rgba(59,130,246,.18);
        color: #3b82f6;
    }

.ai-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 14.4px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: .2s;
    color: #2d2d42;
}

    .btn:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

.btn-primary {
    background: #3b82f6;
}

    .btn-primary:hover:not(:disabled) {
        background: #2563eb;
    }

.btn-success {
    background: #22c55e;
}

    .btn-success:hover:not(:disabled) {
        background: #16a34a;
    }

.btn-danger {
    background: #ef4444;
}

    .btn-danger:hover:not(:disabled) {
        background: #dc2626;
    }

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(0,0,0,.06);
    color: #9e9eb0;
}

    .btn-ghost:hover:not(:disabled) {
        border-color: #3b82f6;
        color: #3b82f6;
    }

.btn-sm {
    padding: 5px 10px;
    font-size: 13.2px;
}

/* ── Mode Badge ── */
.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 7px;
    font-weight: 700;
    font-size: 13.2px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.mode-badge-lg {
    padding: 7px 16px;
    font-size: 15.6px;
}

.mode-advisory {
    background: #854d0e;
    color: #fef08a;
}

.mode-auto {
    background: #166534;
    color: #86efac;
}

/* ── KPI ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(155px,1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.kpi {
    background: linear-gradient(135deg,#fffefa,rgba(20,32,58,.9));
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    transition: .2s;
}

    .kpi:hover {
        border-color: rgba(0,0,0,.06);
    }

.kpi-value {
    font-size: 31.2px;
    font-weight: 800;
    color: #38bdf8;
    line-height: 1.2;
}

.kpi-label {
    font-size: 12px;
    color: #9e9eb0;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.kpi-sub {
    font-size: 10.8px;
    color: #475569;
    margin-top: 2px;
}

.kv-green {
    color: #22c55e;
}

.kv-red {
    color: #ef4444;
}

.kv-orange {
    color: #f59e0b;
}

.kv-gray {
    color: #c5c5d0;
}

/* ── Legend ── */
.ai-legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #9e9eb0;
}

.legend-dot {
    width: 10px;
    height: 4px;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════
   MAIN LAYOUT: Room Grid + Detail Sidebar
   ═══════════════════════════════════════════════════════════ */
.ai-main-layout {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.ai-main-left {
    flex: 1;
    min-width: 0;
}

/* ── Room Grid (bigger cards) ── */
.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(300px,1fr));
    gap: 12px;
}

.room-card {
    background: #fffefa;
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 12px;
    padding: 16px 18px;
    border-left: 5px solid #475569;
    cursor: pointer;
    transition: .2s;
    position: relative;
}

    .room-card:hover {
        border-color: rgba(0,0,0,.06);
        transform: translateY(-1px);
    }

    .room-card.selected {
        border-color: #3b82f6;
        box-shadow: 0 0 16px rgba(59,130,246,.25);
    }

    .room-card.occupied {
        border-left-color: #22c55e;
    }

    .room-card.guest-out {
        border-left-color: #10b981;
        border-left-style: dashed;
    }

    .room-card.vacant-off {
        border-left-color: #475569;
    }

    .room-card.vacant-on {
        border-left-color: #ef4444;
        animation: pulse 2s infinite;
    }

    .room-card.housekeeping {
        border-left-color: #f59e0b;
    }

    .room-card.pre-condition {
        border-left-color: #7c3aed;
    }

    .room-card.maintenance {
        border-left-color: #6b7280;
        border-left-style: dotted;
    }

    .room-card.checkout-buffer {
        border-left-color: #f97316;
    }

@keyframes pulse {
    0%,100% {
        opacity: 1
    }

    50% {
        opacity: .7
    }
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.room-code {
    font-size: 28.8px;
    font-weight: 800;
    color: #2d2d42;
    line-height: 1;
}

.room-name {
    font-size: 13.2px;
    color: #9e9eb0;
    margin-top: 2px;
}

.state-badge {
    font-size: 10.8px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.state-occupied {
    background: rgba(34,197,94,.12);
    color: #22c55e;
}

.state-guest-out {
    background: rgba(16,185,129,.12);
    color: #10b981;
}

.state-vacant-off {
    background: rgba(100,116,139,.15);
    color: #c5c5d0;
}

.state-vacant-on {
    background: rgba(239,68,68,.12);
    color: #ef4444;
}

.state-housekeeping {
    background: rgba(245,158,11,.12);
    color: #f59e0b;
}

.state-pre-condition {
    background: rgba(124,58,237,.08);
    color: #7c3aed;
}

.state-maintenance {
    background: rgba(107,114,128,.15);
    color: #9ca3af;
}

.state-checkout-buffer {
    background: rgba(249,115,22,.12);
    color: #f97316;
}

.room-body {
    font-size: 14.4px;
    color: #9e9eb0;
    line-height: 1.7;
}

.room-power-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}

.room-relay {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 15.6px;
}

.relay-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

    .relay-dot.on {
        background: #22c55e;
        box-shadow: 0 0 6px #22c55e;
    }

    .relay-dot.off {
        background: #ef4444;
    }

.room-divider {
    color: #334155;
}

.room-power {
    font-size: 26.4px;
    font-weight: 800;
    color: #2d2d42;
}

    .room-power small {
        font-size: 15.6px;
        font-weight: 600;
        color: #9e9eb0;
    }

.room-electrical {
    font-size: 13.2px;
    color: #c5c5d0;
}

.room-occupant {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    font-size: 14.4px;
    color: #3b82f6;
}

.room-timer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 5px;
    background: rgba(245,158,11,.08);
    border: 1px solid rgba(245,158,11,.2);
    font-size: 12px;
    color: #f59e0b;
    font-weight: 600;
}

.room-ai-note {
    font-size: 12px;
    color: #475569;
    margin-top: 5px;
    font-style: italic;
}

.waste-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(239,68,68,.12);
    border: 1px solid rgba(239,68,68,.3);
    color: #ef4444;
    font-size: 9.6px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.savings-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(34,197,94,.12);
    border: 1px solid rgba(34,197,94,.3);
    color: #22c55e;
    font-size: 9.6px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════
   DETAIL SIDEBAR (click phòng → hiện bên phải)
   ═══════════════════════════════════════════════════════════ */
.detail-panel {
    border-radius: 14px;
    padding: 18px;
    min-width: 340px;
    max-width: 380px;
    position: sticky;
    top: 20px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

.detail-room-code {
    font-size: 43.2px;
    font-weight: 800;
    color: #2d2d42;
    line-height: 1;
}

.detail-room-name {
    font-size: 14.4px;
    color: #9e9eb0;
    margin-top: 3px;
}

.detail-section {
    margin-top: 14px;
}

.detail-section-title {
    font-size: 13.2px;
    font-weight: 700;
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,0,0,.01);
    font-size: 14.4px;
    color: #9e9eb0;
}

    .detail-row:last-child {
        border-bottom: none;
    }

    .detail-row span:last-child {
        color: #2d2d42;
        font-weight: 600;
    }

.detail-elec-grid {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 8px;
}

.detail-elec-item {
    text-align: center;
    padding: 10px 6px;
    background: rgba(0,0,0,.03);
    border-radius: 8px;
}

.detail-elec-value {
    font-size: 19.2px;
    font-weight: 700;
    color: #2d2d42;
}

    .detail-elec-value small {
        font-size: 13.2px;
        color: #9e9eb0;
    }

.detail-elec-label {
    font-size: 10.8px;
    color: #c5c5d0;
    margin-top: 2px;
}

/* ── Timeline ── */
.detail-timeline {
    margin-top: 4px;
}

.timeline-item {
    display: flex;
    gap: 10px;
    padding: 7px 0;
    border-left: 2px solid rgba(0,0,0,.06);
    margin-left: 6px;
    padding-left: 14px;
    position: relative;
}

    .timeline-item::before {
        content: '';
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #3b82f6;
        position: absolute;
        left: -5px;
        top: 11px;
    }

    .timeline-item.action-turn-off::before {
        background: #ef4444;
    }

    .timeline-item.action-turn-on::before {
        background: #22c55e;
    }

.timeline-time {
    font-size: 12px;
    color: #c5c5d0;
    min-width: 38px;
    padding-top: 1px;
}

.timeline-text {
    font-size: 13.2px;
    color: #9e9eb0;
    line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════ */
.panel {
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

.panel-title {
    font-size: 16.8px;
    font-weight: 700;
    color: #2d2d42;
}

.panel-sub {
    font-size: 12px;
    color: #c5c5d0;
    margin-top: 2px;
}

.panel-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.table-wrap {
    overflow-x: hidden;
}

.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.2px;
    table-layout: fixed;
}

    .ai-table th {
        text-align: left;
        padding: 8px 10px;
        font-size: 12px;
        font-weight: 600;
        color: #9e9eb0;
        text-transform: uppercase;
        letter-spacing: .5px;
        background: rgba(0,0,0,.03);
        border-bottom: 1px solid rgba(0,0,0,.06);
    }

    .ai-table td {
        padding: 7px 10px;
        border-bottom: 1px solid rgba(0,0,0,.01);
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ai-table tr:hover {
        background: rgba(0,0,0,.01);
    }

    .ai-table th:nth-child(1) {
        width: 65px;
    }

    .ai-table th:nth-child(2) {
        width: 55px;
    }

    .ai-table th:nth-child(3) {
        width: 60px;
    }

    .ai-table th:nth-child(4) {
        width: 130px;
    }

    .ai-table th:nth-child(5) {
        width: 55px;
    }

    .ai-table th:nth-child(6) {
        width: 35px;
    }

    .ai-table td:last-child, .ai-table th:last-child {
        white-space: normal;
        word-break: break-word;
    }

.log-table-wrap .ai-table th:nth-child(7) {
    width: 55px;
}

.action-on {
    color: #22c55e;
    font-weight: 700;
}

.action-off {
    color: #ef4444;
    font-weight: 700;
}

.action-alert {
    color: #f59e0b;
    font-weight: 600;
}

.action-none {
    color: #c5c5d0;
}

/* ═══════════════════════════════════════════════════════════
   CONFIG TAB
   ═══════════════════════════════════════════════════════════ */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(320px,1fr));
    gap: 14px;
}

.config-section {
    border-radius: 12px;
    padding: 16px;
}

.config-title {
    font-size: 14.4px;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(0,0,0,.01);
    font-size: 14.4px;
    color: #9e9eb0;
}

    .config-row:last-child {
        border-bottom: none;
    }

.config-input {
    background: rgba(0,0,0,.03);
    border: 1px solid #e0ddd6;
    color: #2d2d42;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 14.4px;
    width: 65px;
    text-align: right;
}

    .config-input:focus {
        border-color: #3b82f6;
        outline: none;
    }

.excluded-tag {
    background: rgba(59,130,246,.18);
    color: #3b82f6;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 14.4px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.ai-select {
    appearance: none;
    background: rgba(0,0,0,.03);
    border: 1px solid #e0ddd6;
    color: #2d2d42;
    padding: 6px 24px 6px 10px;
    border-radius: 7px;
    font-size: 13.2px;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   SELECTOR BAR (Project → Site)
   ═══════════════════════════════════════════════════════════ */
.alerts-selector-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(90deg,#fffefa,rgba(8,14,31,.95));
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 14px;
    padding: 10px 18px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.als-label {
    color: #9e9eb0;
    font-size: 13.2px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.als-wrap {
    position: relative;
}

    .als-wrap select {
        appearance: none;
        background: rgba(0,0,0,.03);
        border: 1px solid #e0ddd6;
        color: #2d2d42;
        padding: 8px 32px 8px 12px;
        border-radius: 10px;
        font-size: 15.6px;
        min-width: 220px;
        cursor: pointer;
    }

        .als-wrap select:focus {
            border-color: rgba(184,137,46,.1);
            outline: none;
        }

.als-caret {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #c5c5d0;
    pointer-events: none;
    font-size: 14.4px;
}

.als-arrow {
    color: #475569;
    font-size: 21.6px;
}

.als-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.als-info-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.als-info-text {
    font-size: 15.6px;
    color: #9e9eb0;
}

    .als-info-text strong {
        color: #2d2d42;
    }

/* ── Misc ── */
.ai-alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14.4px;
}

    .ai-alert.error {
        background: rgba(239,68,68,.12);
        border: 1px solid rgba(239,68,68,.3);
        color: #ef4444;
    }

.ai-placeholder {
    text-align: center;
    padding: 60px;
    color: #c5c5d0;
    font-size: 16.8px;
}

/* ── Responsive ── */
@media (max-width:1100px) {
    .ai-main-layout {
        flex-direction: column;
    }

    .detail-panel {
        min-width: 100%;
        max-width: 100%;
        position: static;
    }
}

@media (max-width:768px) {
    .ai-topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .kpi-grid {
        grid-template-columns: repeat(2,1fr);
    }

    .room-grid {
        grid-template-columns: 1fr;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════════════════════════
   DARK THEME: Select / Option / OptGroup
   Fix dropdown trắng khi mở trên Chrome/Edge
   ══════════════════════════════════════════════════════════════ */
select,
.als-wrap select {
    background-color: #fffefa !important;
    color: #2d2d42 !important;
}

    select option {
        background-color: #fffefa;
        color: #2d2d42;
        padding: 4px 8px;
    }

        select option:checked {
            background-color: rgba(184,137,46,.08);
            color: #2d2d42;
        }

    select optgroup {
        background-color: #f4f1ec;
        color: #9e9eb0;
        font-weight: 700;
    }

        select optgroup option {
            background-color: #fffefa;
            color: #2d2d42;
            font-weight: 400;
        }

.ai-select option {
    background-color: #fffefa;
    color: #2d2d42;
}

.ai-select optgroup {
    background-color: #f4f1ec;
    color: #9e9eb0;
}
