/* =============================================================================
   SCHEDULER / CALENDÁRIO INTERATIVO (ESTILO BACKOFFICE)
   Caminho: front/pages/club/css/reservas.css
   ============================================================================= */

/* Cabeçalho de Controlos do Scheduler (Estilo React/SaaS) */
.scheduler-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.scheduler-date-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.btn-date-arrow {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-date-arrow:hover {
    background-color: var(--bg-main);
    border-color: var(--text-muted);
}

.selected-date-label {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    min-width: 190px;
    text-align: center;
    user-select: none;
    letter-spacing: -0.01em;
}

.scheduler-actions-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-scheduler-action {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 1.15rem;
    border-radius: var(--radius-button);
    font-size: 0.825rem;
    font-weight: 750;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-fast);
}

.btn-scheduler-action:hover {
    background-color: var(--bg-main);
    border-color: var(--text-muted);
}

@media (max-width: 768px) {
    .scheduler-controls-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
    
    .scheduler-date-nav-wrapper {
        justify-content: space-between;
        width: 100%;
    }
    
    .selected-date-label {
        min-width: unset;
        flex-grow: 1;
    }
    
    .scheduler-actions-wrapper {
        width: 100%;
    }
    
    .btn-scheduler-action {
        flex: 1;
        justify-content: center;
    }
}

/* Scheduler Card Container */
.scheduler-container-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.scheduler-legend-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.legend-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

.legend-color-box.free {
    background-color: rgba(37, 99, 235, 0.15);
    border: 1.5px dashed var(--primary);
}

.legend-color-box.occupied {
    background-color: #e2e8f0;
    border: 1px solid #cbd5e1;
}

.legend-color-box.unavailable {
    background-color: rgba(239, 68, 68, 0.05);
    background-image: repeating-linear-gradient(45deg, rgba(239, 68, 68, 0.1) 0px, rgba(239, 68, 68, 0.1) 2px, transparent 2px, transparent 6px);
}

/* Grelha do Scheduler */
.scheduler-horizontal-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.scheduler-grid-wrapper {
    min-width: 900px;
    width: 100%;
    position: relative;
}

.scheduler-hours-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-input);
}

.court-header-cell {
    width: 160px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #ffffff;
    position: sticky;
    left: 0;
    z-index: 10;
}

.scheduler-timeline-wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 160px;
    right: 0;
    pointer-events: none;
    z-index: 9;
}

.hours-cells-row {
    display: flex;
    flex-grow: 1;
    position: relative;
}

.hour-header-cell {
    flex: 1;
    min-width: 45px;
    text-align: center;
    padding: 0.85rem 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
}

.hour-header-cell:last-child {
    border-right: none;
}

/* Linhas do Scheduler */
.court-scheduler-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    min-height: 75px;
    position: relative;
}

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

.court-name-cell {
    width: 160px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
    position: sticky;
    left: 0;
    z-index: 10;
}

.court-title {
    font-weight: 750;
    font-size: 0.875rem;
    color: var(--text-main);
    line-height: 1.2;
}

.court-subtitle {
    font-size: 0.725rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-weight: 600;
}

.court-slots-container {
    display: flex;
    flex-grow: 1;
    position: relative;
}

/* Linhas de Grelha de Fundo */
.hour-grid-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    pointer-events: none;
    z-index: 1;
}

.hour-backdrop-cell {
    flex: 1;
    min-width: 45px;
    border-right: 1px solid var(--border-color);
    height: 100%;
}

.hour-backdrop-cell:last-child {
    border-right: none;
}

/* Blocos Indisponíveis */
.unavailable-block {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: rgba(239, 68, 68, 0.03);
    background-image: repeating-linear-gradient(
        45deg,
        rgba(239, 68, 68, 0.08) 0px,
        rgba(239, 68, 68, 0.08) 2px,
        transparent 2px,
        transparent 6px
    );
    z-index: 6;
    pointer-events: none;
    border-right: 1px solid rgba(239, 68, 68, 0.05);
}

.unavailable-blocks-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    pointer-events: none;
}

/* Camada Interativa */
.bookings-interactive-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
}

/* Indicador de Seleção no Hover */
.scheduler-slot-hover-indicator {
    position: absolute;
    top: 0px;
    bottom: 0px;
    background-color: rgba(37, 99, 235, 0.15);
    border: 2px dashed var(--primary);
    border-radius: 4px;
    pointer-events: none;
    z-index: 4;
    transition: opacity 0.1s ease;
}

/* Cartões de Reserva Ocupados */
.booking-card {
    position: absolute;
    top: 0px;
    bottom: 0px;
    border-radius: 0px;
    padding: 0.5rem;
    font-size: 0.725rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.15rem;
    z-index: 5;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
}

.booking-card.status-occupied {
    background-color: #e2e8f0;
    color: var(--text-muted);
    cursor: not-allowed;
}

.booking-card.status-selected-temp {
    background: var(--primary-gradient);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    z-index: 8;
}

.booking-card-name {
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 100%;
}

.booking-card-time {
    font-size: 0.65rem;
    opacity: 0.8;
    font-weight: 600;
}

/* Indicador de Tempo Atual */
.current-time-line {
    border-left: 2px solid var(--danger) !important;
    width: 0 !important;
    background: transparent !important;
    z-index: 6;
}

.current-time-dot {
    position: absolute;
    top: 0;
    left: -4.5px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
}

/* Scheduler Popover */
.scheduler-popover {
    position: fixed;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 180px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: auto;
}

.scheduler-popover.active {
    opacity: 1;
}

/* Pequeno triângulo apontando para baixo */
.scheduler-popover::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

/* Inversão para o topo (quando o popover abre abaixo do clique) */
.scheduler-popover.position-below::after {
    top: -6px;
    bottom: auto;
    border-right: none;
    border-bottom: none;
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

.popover-title {
    font-size: 0.725rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.35rem;
    text-align: center;
}

.popover-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-input);
    cursor: pointer;
    text-align: center;
    transition: var(--transition-fast);
}

.popover-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.popover-no-time {
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 600;
    text-align: center;
    padding: 0.5rem;
}

.booking-floating-bar-pill {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 0);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 26px;
    padding: 0.5rem 0.5rem 0.5rem .65rem;
    z-index: 2000;
    opacity: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    transition: opacity 0.2s ease, border-radius 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0.3s, padding 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
    pointer-events: auto;
}

.booking-floating-bar-pill.active {
    opacity: 1;
}

.booking-floating-bar-pill.expanded {
    border-radius: 26px;
    transition: opacity 0.2s ease, border-radius 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0s, padding 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0s;
}

.floating-pill-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.floating-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981; /* Verde esmeralda */
}

.floating-pill-text {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.825rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* Estilos da Linha Compacta Principal */
.floating-pill-main-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
}

/* Botão toggle do info */
.btn-floating-info-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 0.6rem 1.15rem;
    border-radius: 9999px;
    cursor: pointer;
    display: inline-flex; /* Sempre visível */
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    transition: var(--transition-fast);
}

.btn-floating-info-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Toggle de estados do botão de info */
#booking-floating-bar .btn-icon-close,
#booking-floating-bar .btn-text-close {
    display: none;
}
#booking-floating-bar .btn-icon-details,
#booking-floating-bar .btn-text-details {
    display: inline-flex;
    align-items: center;
}
#booking-floating-bar.expanded .btn-icon-details,
#booking-floating-bar.expanded .btn-text-details {
    display: none;
}
#booking-floating-bar.expanded .btn-icon-close,
#booking-floating-bar.expanded .btn-text-close {
    display: inline-flex;
    align-items: center;
}

/* Quando expandido, muda para outline vermelho */
#booking-floating-bar.expanded .btn-floating-info-toggle {
    border-color: #ef4444;
    color: #ef4444;
    background: transparent;
}

#booking-floating-bar.expanded .btn-floating-info-toggle:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #f87171;
    color: #f87171;
}

/* Conteúdo de Detalhes Expandido */
.floating-pill-details-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0s, opacity 0.15s ease 0s;
    width: 100%;
}

.booking-floating-bar-pill.expanded .floating-pill-details-content {
    max-height: 250px;
    opacity: 1;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 0.75rem;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.15s, opacity 0.2s ease 0.45s;
    padding: 0.75rem;

}

.floating-details-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.floating-details-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.floating-details-label {
    font-weight: 500;
}

.floating-details-value {
    font-weight: 700;
    color: #ffffff;
}

.floating-pill-divider {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.15);
}

.floating-pill-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-floating-cancel-pill {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.7rem 1.15rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-floating-cancel-pill:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.btn-floating-confirm-pill {
    background: #ffffff;
    border: none;
    color: #0f172a;
    padding: 0.75rem 1.6rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition-fast);
}

.btn-floating-confirm-pill:hover {
    background: #f1f5f9;
}

/* Responsivo para telemóveis */
@media (max-width: 768px) {
    .booking-floating-bar-pill {
        position: fixed;
        bottom: 80px; /* Limpar rodapé móvel (ligeiramente acima) */
        left: 12px;
        right: 12px;
        transform: none;
        width: calc(100% - 24px);
        box-sizing: border-box;
        border-radius: 26px; /* Inicialmente pill */
        padding: 0.5rem 0.5rem 0.5rem .6rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        transition: border-radius 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0.3s, padding 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0.3s, bottom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .booking-floating-bar-pill.expanded {
        bottom: 24px; /* Garante que a barra expandida fica sempre na base (24px) */
        border-radius: 26px;
        transition: border-radius 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0s, padding 0.15s cubic-bezier(0.4, 0, 0.2, 1) 0s, bottom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    body:has(.mobile-bottom-wrapper.collapsed) .booking-floating-bar-pill:not(.expanded) {
        bottom: 24px; /* Desloca para baixo (ligeiramente acima de 16px) quando a navbar colapsa */
    }

    /* Se a barra estiver expandida, força a navbar de rodapé móvel a manter-se escondida/oculta */
    body:has(#booking-floating-bar.expanded) .mobile-bottom-wrapper {
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.3s ease;
    }



    .floating-pill-main-row {
        gap: 0.5rem;
        justify-content: space-between;
    }

    .floating-pill-info {
        gap: 0.4rem;
        display: flex;
        align-items: center;
    }

    .btn-floating-info-toggle {
        display: inline-flex; /* Visível no Mobile */
    }


    .floating-pill-divider {
        display: none; /* Ocultar divisor no mobile */
    }

    .floating-pill-actions {
        gap: 0.25rem;
        display: flex;
        align-items: center;
    }

    .btn-floating-confirm-pill {
        padding: 0.7rem 1.25rem;
        font-size: 0.8rem;
    }

    .btn-floating-cancel-pill {
        font-size: 0.8rem;
        padding: 0.65rem 0.9rem;
    }

    .hour-header-cell,
    .hour-backdrop-cell {
        min-width: 70px !important;
    }

    .scheduler-grid-wrapper {
        min-width: 100% !important;
        width: max-content !important;
    }

    .court-header-cell,
    .court-name-cell {
        width: 120px !important;
        padding: 0.75rem 0.5rem !important;
    }

    .scheduler-timeline-wrapper {
        left: 120px !important;
    }
}
