/**
 * Agenda View - Time Grid Estilo Google Calendar
 * Design Mobile-First Responsivo
 */

/* Container Principal */
.agenda-view {
    padding: 0;
    max-width: 100%;
    margin: 0;
}

/* Header da Agenda */
.agenda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.agenda-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.agenda-title i {
    color: var(--primary);
}

.agenda-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* View Toggle */
.view-toggle {
    display: flex;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.view-toggle-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-toggle-btn.active {
    background: var(--primary);
    color: white;
}

.view-toggle-btn:hover:not(.active) {
    background: var(--bg-tertiary);
}

/* Navigation */
.agenda-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--primary-dark);
}

.nav-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.current-date {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 150px;
    text-align: center;
}

/* Toggle Ver Outros PTs */
.toggle-pts-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.toggle-pts-label {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-pts-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-pts-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-pts-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-pts-label input:checked + .toggle-pts-slider {
    background-color: var(--primary);
}

.toggle-pts-label input:checked + .toggle-pts-slider:before {
    transform: translateX(20px);
}

.toggle-pts-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========== MONTH VIEW (Overview) ========== */
.agenda-month-view {
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border-color);
}

.weekday-header {
    background: var(--bg-secondary);
    padding: 8px 4px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.day-cell {
    background: var(--bg-primary);
    min-height: 80px;
    padding: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.day-cell:hover {
    background: var(--bg-tertiary);
}

.day-cell.today {
    background: rgba(59, 130, 246, 0.1);
}

.day-cell.other-month {
    opacity: 0.4;
}

.day-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.day-cell.today .day-number {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mini slots no mês */
.day-slots {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.day-slot {
    font-size: 0.625rem;
    padding: 2px 4px;
    border-radius: 3px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.day-slot:hover {
    opacity: 0.8;
}

/* Cores PT */
.pt-nr { background: #3b82f6; }
.pt-gil { background: #6b7280; }
.pt-jm { background: #f97316; }
.pt-jp { background: #eab308; }
.pt-dn { background: #22c55e; }

/* ========== DAY VIEW (Time Grid) ========== */
.agenda-day-view {
    background: var(--bg-primary);
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Time Grid Container */
.time-grid {
    display: grid;
    grid-template-columns: 60px repeat(5, minmax(140px, 1fr));
    min-width: 800px;
}

/* Header das Colunas */
.grid-header {
    display: contents;
}

.time-column-header {
    background: var(--bg-secondary);
    padding: 12px 8px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--border-color);
}

.time-column-header.pt-header {
    color: white;
}

.time-column-header.pt-nr { background: #3b82f6; }
.time-column-header.pt-gil { background: #6b7280; }
.time-column-header.pt-jm { background: #f97316; }
.time-column-header.pt-jp { background: #eab308; color: #000; }
.time-column-header.pt-dn { background: #22c55e; }

/* Linhas de Tempo */
.time-row {
    display: contents;
}

.time-label {
    background: var(--bg-secondary);
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    border-right: 2px solid var(--border-color);
}

.time-slot {
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    min-height: 80px;
    padding: 4px;
    position: relative;
    transition: background 0.2s;
}

.time-slot:hover {
    background: var(--bg-tertiary);
}

/* Cliente no Slot */
.slot-client {
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 2px;
}

.slot-client:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.slot-client .client-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-client .client-time {
    font-size: 0.625rem;
    opacity: 0.9;
    margin-top: 2px;
}

.slot-client.duo::before {
    content: '👥 ';
}

/* PT Labels no mobile */
.pt-mobile-label {
    display: none;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 4px;
}

/* ========== RESPONSIVE ========== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .agenda-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .agenda-controls {
        width: 100%;
        justify-content: space-between;
    }

    .time-grid {
        grid-template-columns: 50px repeat(5, minmax(120px, 1fr));
        min-width: 700px;
    }

    .slot-client {
        font-size: 0.7rem;
        padding: 4px 6px;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .agenda-view {
        padding: 8px;
    }

    .agenda-header {
        padding: 12px;
        margin-bottom: 12px;
    }

    .agenda-title {
        font-size: 1.125rem;
    }

    .view-toggle-btn {
        padding: 6px 12px;
        font-size: 0.8125rem;
    }

    .current-date {
        font-size: 0.875rem;
        min-width: 100px;
    }

    /* Month View Mobile */
    .week-grid {
        gap: 1px;
    }

    .day-cell {
        min-height: 60px;
        padding: 2px;
    }

    .day-number {
        font-size: 0.75rem;
    }

    .day-slot {
        font-size: 0.5rem;
        padding: 1px 2px;
    }

    /* Day View Mobile - Scroll Horizontal */
    .agenda-day-view {
        margin: 0 -8px;
        padding: 0 8px;
    }

    .time-grid {
        min-width: 700px;
    }

    .time-label {
        font-size: 0.625rem;
        padding: 4px 2px;
    }

    .time-column-header {
        font-size: 0.75rem;
        padding: 8px 4px;
    }

    .time-slot {
        min-height: 60px;
    }

    /* PT Mobile Labels para contexto */
    .pt-mobile-label {
        display: block;
    }
}

/* Mobile Pequeno (< 480px) */
@media (max-width: 480px) {
    .week-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .weekday-header {
        font-size: 0.625rem;
        padding: 4px 2px;
    }

    .day-cell {
        min-height: 50px;
    }

    .time-grid {
        min-width: 600px;
    }

    .slot-client {
        font-size: 0.625rem;
        padding: 2px 4px;
    }
}

/* ========== MODAL DETALHES ========== */
.agenda-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.agenda-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.agenda-modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agenda-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.close-modal-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.agenda-modal-body {
    padding: 16px;
}

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    width: 80px;
    flex-shrink: 0;
}

.detail-value {
    font-size: 0.8125rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ========== LEGENDA ========== */
.agenda-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.pt-nr { background: #3b82f6; }
.legend-dot.pt-gil { background: #6b7280; }
.legend-dot.pt-jm { background: #f97316; }
.legend-dot.pt-jp { background: #eab308; }
.legend-dot.pt-dn { background: #22c55e; }

/* ========== LOADING ========== */
.agenda-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== EMPTY STATE ========== */
.agenda-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.agenda-empty i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 16px;
    display: block;
}

.agenda-empty p {
    font-size: 0.875rem;
}
