/* salas.css — Reserva de Salas de Reunião (Fase 59)
 * Agenda visual: colunas por sala com header colorido, slots de 30min
 * clicáveis, blocos de reserva com avatar + cor do corretor, ✕ no hover.
 * Escopado sob #view-salas. */

#view-salas:not(.hidden) {
    display: flex;
    flex-direction: column;
    padding: 22px 24px 40px;
}

.salas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.salas-dia-label {
    margin: 2px 0 0;
    color: var(--text-muted, #8a93a3);
    font-size: 13px;
    text-transform: capitalize;
}

.salas-nav {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Toggle Dia | Semana | Mês */
.salas-toggle {
    display: inline-flex;
    background: var(--bg-muted, #eef1f5);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.salas-toggle-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 8px;
    color: var(--text-muted, #5b6b82);
    transition: background .15s ease, color .15s ease;
}

.salas-toggle-btn.active {
    background: var(--bg-surface, #fff);
    color: var(--brand-primary, #0a4dba);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

/* Strip semanal (visão Dia) */
.salas-strip {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.salas-strip-dia {
    flex: 1;
    min-width: 74px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 6px;
    border: 1px solid var(--border, #e3e8ef);
    border-radius: 10px;
    background: var(--bg-surface, #fff);
    cursor: pointer;
    position: relative;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.salas-strip-dia:hover {
    border-color: var(--brand-primary, #0a4dba);
}

.salas-strip-dia.active {
    border-color: var(--brand-primary, #0a4dba);
    background: color-mix(in srgb, var(--brand-primary, #0a4dba) 8%, var(--bg-surface, #fff));
    box-shadow: 0 3px 10px rgba(10, 77, 186, .15);
}

.salas-strip-dia.hoje .salas-strip-num {
    color: var(--brand-primary, #0a4dba);
}

.salas-strip-dow {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted, #8a93a3);
}

.salas-strip-num {
    font-size: 18px;
    font-weight: 800;
}

.salas-strip-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    background: var(--brand-primary, #0a4dba);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    border-radius: 100px;
    padding: 1px 6px;
}

/* Visão Semana: header de dia clicável */
.salas-col-header--dia {
    border: none;
    cursor: pointer;
    border-top: 4px solid transparent;
}

.salas-col-header--dia:hover {
    color: var(--brand-primary, #0a4dba);
}

.salas-col-header--dia.hoje {
    border-top-color: var(--brand-primary, #0a4dba);
    color: var(--brand-primary, #0a4dba);
}

/* Visão Mês */
.salas-mes {
    border: 1px solid var(--border, #e3e8ef);
    border-radius: 12px;
    background: var(--bg-surface, #fff);
    padding: 12px;
}

.salas-mes-head {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 6px;
}

.salas-mes-dow {
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted, #8a93a3);
    padding: 6px 0;
}

.salas-mes-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.salas-mes-cel {
    min-height: 76px;
    border: 1px solid var(--border, #e3e8ef);
    border-radius: 10px;
    background: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 6px 8px;
    transition: border-color .15s ease, background .15s ease;
    text-align: left;
}

.salas-mes-cel:hover {
    border-color: var(--brand-primary, #0a4dba);
    background: color-mix(in srgb, var(--brand-primary, #0a4dba) 5%, transparent);
}

.salas-mes-cel--vazia {
    border: none;
    cursor: default;
    background: none;
}

.salas-mes-cel.hoje {
    border-color: var(--brand-primary, #0a4dba);
    border-width: 2px;
}

.salas-mes-cel.tem-reserva {
    background: color-mix(in srgb, var(--brand-primary, #0a4dba) 4%, transparent);
}

.salas-mes-num {
    font-size: 13px;
    font-weight: 800;
}

.salas-mes-dots {
    display: flex;
    gap: 3px;
}

.salas-mes-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.salas-mes-count {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted, #8a93a3);
}

/* Modal de reserva alinhado ao padrão visual global, mantendo o formato compacto. */
.salas-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 11, 24, .45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 20px;
    animation: fadeIn .25s var(--transition-premium, ease);
}

.salas-modal-box {
    background: var(--surface, var(--bg-surface, #fff));
    color: var(--text, #1c2434);
    border: 1px solid var(--border, #dfe3ea);
    border-radius: var(--modal-radius, 12px);
    padding: 0;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--modal-shadow, 0 18px 50px rgba(0, 0, 0, .3));
    animation: modalIn .35s var(--transition-premium, ease);
}

.salas-modal-box--admin {
    max-width: 760px;
}

.salas-admin-content {
    padding: 20px 24px 22px;
}

.salas-modal-header {
    min-height: var(--modal-header-min-height, 56px);
    padding: 0 var(--modal-padding-x, 24px);
    border-bottom: 1px solid var(--border, #dfe3ea);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.salas-modal-titulo {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #1c2434);
}

.salas-modal-close {
    width: var(--modal-close-size, 34px);
    height: var(--modal-close-size, 34px);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted, #6b7280);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.salas-modal-close:hover,
.salas-modal-close:focus-visible {
    background: var(--surface-2, #f1f4f8);
    color: var(--text, #1c2434);
    outline: none;
}

.salas-modal-erro {
    display: none;
    background: #fdecea;
    color: #c0392b;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 14px 24px 0;
    font-weight: 600;
    font-size: 13px;
}

.salas-modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 24px 0;
}

.salas-modal-linha {
    display: flex;
    gap: 12px;
}

.salas-modal-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted, #5b6b82);
}

.salas-modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0 11px;
    font-size: 13px;
}

.salas-modal-input:hover { border-color: var(--text-muted, #8a93a3); }
.salas-modal-input:focus {
    border-color: var(--brand-primary, #0a4dba);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary, #0a4dba) 14%, transparent);
    outline: none;
}

.salas-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin: 6px -24px 0;
    padding: 16px 24px;
    border-top: 1px solid var(--border, #dfe3ea);
    background: var(--surface-2, #f8fafc);
}

.salas-modal-footer button {
    min-width: 96px;
    min-height: 38px;
}

@media (max-width: 520px) {
    .salas-modal-overlay { padding: 10px; align-items: flex-end; }
    .salas-modal-box { max-height: calc(100dvh - 20px); border-radius: 12px 12px 0 0; }
    .salas-modal-header { padding: 0 18px; }
    .salas-modal-form { padding: 16px 18px 0; }
    .salas-modal-footer { margin-inline: -18px; padding: 14px 18px; }
    .salas-modal-linha { flex-wrap: wrap; }
    .salas-modal-linha .salas-modal-label { min-width: 120px; }
}

.salas-admin-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.salas-admin-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border, #dfe3ea);
    border-radius: 10px;
    background: var(--surface-2, #f8fafc);
}

.salas-modal-box--admin .salas-modal-footer {
    margin: 0;
}

.salas-nav-btn {
    font-size: 15px;
    padding: 6px 12px;
}

.salas-date {
    width: 150px;
}

.salas-acts {
    display: flex;
    gap: 8px;
}

.salas-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted, #8a93a3);
    font-size: 15px;
}

.salas-empty-dica {
    font-size: 13px;
    margin-top: 6px;
    color: var(--text-muted, #8a93a3);
}

/* ---- Grade ---- */

.salas-grade-wrap {
    overflow-x: auto;
    border: 1px solid var(--border, #e3e8ef);
    border-radius: 12px;
    background: var(--bg-surface, #fff);
}

.salas-grade {
    display: grid;
    min-width: 500px;
}

.salas-col-header {
    position: sticky;
    top: 0;
    background: var(--bg-surface, #fff);
    font-weight: 800;
    font-size: 13px;
    text-align: center;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border, #e3e8ef);
    z-index: 2;
}

.salas-col-header--sala {
    border-top: 4px solid var(--brand-primary, #0a4dba);
    border-radius: 2px 2px 0 0;
}

.salas-col-hora {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border, #e3e8ef);
}

.salas-hora-slot {
    height: 28px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted, #8a93a3);
    text-align: right;
    padding-right: 8px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.salas-col {
    position: relative;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border, #e3e8ef);
}

.salas-col:last-child {
    border-right: none;
}

.salas-slot {
    height: 28px;
    box-sizing: border-box;
    border-bottom: 1px dashed color-mix(in srgb, var(--border, #e3e8ef) 60%, transparent);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s ease;
}

.salas-slot:hover {
    background: color-mix(in srgb, var(--brand-primary, #0a4dba) 8%, transparent);
}

/* ---- Bloco de reserva ---- */

.salas-reserva {
    position: absolute;
    left: 4px;
    right: 4px;
    background: color-mix(in srgb, var(--bg-surface, #fff) 75%, var(--brand-primary, #0a4dba) 6%);
    border: 1px solid var(--border, #e3e8ef);
    border-left: 4px solid var(--brand-primary, #0a4dba);
    border-radius: 8px;
    padding: 4px 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.salas-reserva-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.sala-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand-primary, #0a4dba);
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.salas-reserva-user {
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.salas-reserva-x {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    padding: 1px 4px;
    border-radius: 4px;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity .15s ease;
}

.salas-reserva:hover .salas-reserva-x {
    opacity: .7;
}

.salas-reserva-x:hover {
    opacity: 1 !important;
    color: #d63031;
    background: rgba(214, 48, 49, .1);
}

.salas-reserva-titulo {
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.salas-reserva-hora {
    font-size: 10px;
    color: var(--text-muted, #8a93a3);
    font-weight: 700;
}

/* Dark mode */
html[data-theme="dark"] .salas-reserva {
    background: color-mix(in srgb, var(--bg-surface, #1c2434) 80%, #fff 5%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

/* Foto da sala */
.salas-col-foto {
    width: 100%;
    height: 108px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    margin-bottom: 4px;
}

.salas-admin-thumb {
    width: 34px;
    height: 26px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}

.salas-modal-foto {
    display: none;
    width: 100%;
    max-height: 110px;
    object-fit: cover;
    border-radius: 8px;
}

/* Inputs do modal com altura própria — a classe imoveis-search herda altura
   gigante (280px) fora da view de imóveis e estourava o modal pra 720px+. */
.salas-modal-input,
select.salas-modal-input,
input.salas-modal-input {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    border: 1px solid var(--border, #dfe3ea);
    border-radius: 8px;
    background: var(--bg-surface, #fff);
    color: inherit;
    font-size: 13px;
    font-family: inherit;
}

/* Popover de resumo do dia (hover no strip semanal e no mês) */
.salas-popover {
    position: fixed;
    z-index: 1200;
    background: var(--bg-surface, #fff);
    color: var(--text, #1c2434);
    border: 1px solid var(--border, #e3e8ef);
    border-radius: 10px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .22);
    padding: 10px 12px;
    min-width: 240px;
    max-width: 330px;
    pointer-events: none;
}

.salas-popover-titulo {
    font-size: 12px;
    font-weight: 800;
    text-transform: capitalize;
    margin-bottom: 6px;
    color: var(--brand-primary, #0a4dba);
}

.salas-popover-vazio {
    font-size: 12px;
    color: var(--text-muted, #8a93a3);
    font-style: italic;
}

.salas-popover-linha {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 0;
    font-size: 12px;
    min-width: 0;
}

.salas-popover-hora {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.salas-popover-sala {
    color: var(--text-muted, #5b6b82);
    flex-shrink: 0;
}

.salas-popover-quem {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Slot fora do horário disponível da sala (gestão de horários) */
.salas-slot--indisponivel {
    cursor: default;
    background: repeating-linear-gradient(
        135deg,
        var(--bg-muted, #eef1f5),
        var(--bg-muted, #eef1f5) 4px,
        transparent 4px,
        transparent 8px
    );
}

.salas-slot--indisponivel:hover {
    background: repeating-linear-gradient(
        135deg,
        var(--bg-muted, #eef1f5),
        var(--bg-muted, #eef1f5) 4px,
        transparent 4px,
        transparent 8px
    );
}

/* Modal Gerenciar salas: linhas com nome + horário + foto — precisa quebrar
   linha (modal é compacto de propósito, não pode estourar como o antigo). */
.salas-admin-row {
    flex-wrap: wrap;
    row-gap: 6px;
}

.salas-admin-horario-sep {
    font-size: 12px;
    flex-shrink: 0;
}

.salas-admin-add-titulo {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted, #8a93a3);
    margin-top: 20px;
    margin-bottom: 8px;
}

.salas-admin-add-row input[type="file"] {
    font-size: 11px;
}

@media (max-width: 720px) {
    .salas-modal-box--admin { max-width: 100%; }
    .salas-admin-content { padding: 16px 18px 18px; }
    .salas-admin-row { align-items: stretch; }
    .salas-admin-row > input[type="text"],
    .salas-admin-add-row > input:first-child { flex-basis: calc(100% - 24px) !important; }
    .salas-admin-add-row input[type="file"] { max-width: 100% !important; width: 100%; }
}
