/* 📱 CONFIGURAÇÃO RESPONSIVA GLOBAL */

/* Variáveis CSS para consistência */
:root {
    --mobile-breakpoint: 768px;
    --small-mobile-breakpoint: 480px;
    --touch-target-min: 44px;
    --mobile-padding: 1rem;
    --mobile-padding-small: 0.5rem;
    --mobile-font-size: 16px; /* Evita zoom no iOS */
    
    /* Cores para melhor visibilidade mobile */
    --mobile-event-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    --mobile-touch-feedback: rgba(79, 172, 254, 0.15);
    --mobile-text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Reset e base para mobile */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    body {
        font-size: var(--mobile-font-size);
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Evitar zoom acidental */
    input, select, textarea, button {
        font-size: var(--mobile-font-size);
    }
    
    /* Scroll suave em mobile */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
}

/* Touch targets mínimos */
.touch-target,
button,
.btn,
.fc-button,
.nav-link,
.dropdown-toggle {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

/* Estados de touch feedback */
@media (hover: none) and (pointer: coarse) {
    .touch-feedback:active,
    .btn:active,
    .fc-button:active,
    .fc-event:active,
    .card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Melhorias específicas para calendário mobile */
@media (max-width: 768px) {
    /* Container principal */
    .calendar-container {
        padding: var(--mobile-padding-small);
        margin: 0;
    }
    
    /* Eventos mais visíveis */
    .fc-event {
        font-weight: 700 !important;
        text-shadow: var(--mobile-text-shadow) !important;
        box-shadow: var(--mobile-event-shadow) !important;
        border: 2px solid rgba(255, 255, 255, 0.4) !important;
        min-height: 32px !important;
        font-size: 0.75rem !important;
        line-height: 1.2 !important;
        backdrop-filter: blur(5px);
    }
    
    /* Títulos de eventos quebram linha */
    .fc-event-title {
        white-space: normal !important;
        word-break: break-word !important;
        font-weight: 700 !important;
        text-shadow: var(--mobile-text-shadow) !important;
    }
    
    /* Células do calendário maiores */
    .fc-daygrid-day {
        min-height: 85px !important;
        position: relative;
    }
    
    .fc-daygrid-day:active {
        background-color: var(--mobile-touch-feedback) !important;
    }
    
    /* Números dos dias mais visíveis */
    .fc-daygrid-day-number {
        font-weight: 700 !important;
        color: #374151 !important;
    }
    
    /* Hoje destacado */
    .fc-day-today .fc-daygrid-day-number {
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
        color: white;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0.25rem;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    }
    
    /* Header do calendário */
    .fc-header-toolbar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem !important;
    }
    
    .fc-toolbar-title {
        order: -1;
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    /* Botões de navegação */
    .fc-button {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.8rem !important;
        min-height: var(--touch-target-min);
        border-radius: 8px !important;
    }
    
    .fc-button-group {
        display: flex;
        gap: 0.25rem;
        justify-content: center;
    }
    
    /* Modals mobile-friendly */
    .modal-dialog {
        margin: 0.5rem;
        width: calc(100% - 1rem);
        max-height: 95vh;
    }
    
    .modal-content {
        border-radius: 15px;
        overflow: hidden;
    }
    
    .modal-header {
        padding: 1rem 1.25rem;
        position: relative;
    }
    
    .modal-body {
        padding: 1rem 1.25rem;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Forms mobile */
    .form-control {
        font-size: var(--mobile-font-size);
        min-height: var(--touch-target-min);
        padding: 0.75rem 1rem;
        border-radius: 10px;
    }
    
    .form-select {
        font-size: var(--mobile-font-size);
        min-height: var(--touch-target-min);
        padding: 0.75rem 1rem;
    }
    
    .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        color: #374151;
    }
}

/* Mobile muito pequeno (<480px) */
@media (max-width: 480px) {
    .fc-event {
        font-size: 0.65rem !important;
        padding: 0.25rem 0.5rem !important;
        min-height: 28px !important;
    }
    
    .fc-daygrid-day {
        min-height: 75px !important;
    }
    
    .fc-daygrid-day-number {
        font-size: 0.8rem !important;
        padding: 0.25rem !important;
    }
    
    .fc-button {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
    }
    
    .fc-toolbar-title {
        font-size: 1rem !important;
    }
    
    .modal-dialog {
        margin: 0.25rem;
        width: calc(100% - 0.5rem);
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .fc-daygrid-day {
        min-height: 65px !important;
    }
    
    .fc-header-toolbar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .fc-toolbar-title {
        order: 0;
        margin-bottom: 0;
        font-size: 1rem;
    }
    
    .modal-dialog {
        max-height: 90vh;
    }
}

/* Melhorias para acessibilidade mobile */
@media (max-width: 768px) {
    /* Focus states mais visíveis */
    button:focus,
    .btn:focus,
    .fc-button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid rgba(37, 99, 235, 0.5);
        outline-offset: 2px;
    }
    
    /* Skip links para navegação por teclado */
    .skip-link {
        position: absolute;
        top: -40px;
        left: 6px;
        background: #000;
        color: #fff;
        padding: 8px;
        text-decoration: none;
        border-radius: 4px;
        z-index: 1000;
    }
    
    .skip-link:focus {
        top: 6px;
    }
    
    /* Melhor contraste para textos pequenos */
    .fc-event-time,
    .fc-event-title,
    .small-text {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
    }
}

/* Indicadores de loading mobile-friendly */
.mobile-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10000;
}

.mobile-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Toasts mobile */
@media (max-width: 768px) {
    .toast-container {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        z-index: 1050;
    }
    
    .toast {
        width: 100%;
        margin: 0 0 0.5rem 0;
        border-radius: 12px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
}

/* Animações otimizadas para mobile */
@media (prefers-reduced-motion: no-preference) {
    .fc-event {
        transition: all 0.2s ease;
    }
    
    .fc-event:hover,
    .fc-event:active {
        transform: translateY(-2px) scale(1.02);
    }
}

/* Reduzir animações se preferência for por menos movimento */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}