/**
 * CSS Responsivo
 * Sistema de Controle de Guarda Compartilhada
 */

/* ===== BREAKPOINTS CUSTOMIZADOS ===== */
/* xs: <576px */
/* sm: ≥576px */
/* md: ≥768px */
/* lg: ≥992px */
/* xl: ≥1200px */
/* xxl: ≥1400px */

/* ===== MOBILE FIRST - EXTRA SMALL (XS) ===== */
/* Estilos base para mobile */

/* Navbar mobile */
.navbar-toggler {
    border: none;
    padding: 0.25rem 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.navbar-collapse {
    margin-top: 1rem;
}

.navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Cards em mobile */
.card {
    margin-bottom: 1rem;
}

.card-body {
    padding: 1rem;
}

/* Botões em mobile */
.btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-group-mobile .btn {
    width: 100%;
}

/* Tabelas responsivas */
.table-mobile {
    font-size: 0.875rem;
}

.table-mobile th,
.table-mobile td {
    padding: 0.5rem;
}

/* Ocultar colunas menos importantes em mobile */
.table .d-none-mobile {
    display: none;
}

/* Stack de dados em mobile */
.mobile-stack {
    display: block;
}

.mobile-stack-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.mobile-stack-item:last-child {
    border-bottom: none;
}

.mobile-stack-label {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.mobile-stack-value {
    font-weight: 500;
    text-align: right;
}

/* Forms em mobile */
.form-group-mobile {
    margin-bottom: 1rem;
}

.form-control-mobile {
    font-size: 16px; /* Previne zoom no iOS */
}

/* Modal em mobile */
.modal-mobile {
    padding: 0;
}

.modal-mobile .modal-dialog {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: flex-end;
}

.modal-mobile .modal-content {
    border-radius: 1rem 1rem 0 0;
}

/* ===== SMALL (SM) - ≥576px ===== */
@media (min-width: 576px) {
    /* Navbar */
    .navbar-collapse {
        margin-top: 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.5rem 1rem;
        border-bottom: none;
    }
    
    /* Cards */
    .card-body {
        padding: 1.5rem;
    }
    
    /* Botões */
    .btn-group-mobile {
        flex-direction: row;
        justify-content: center;
    }
    
    .btn-group-mobile .btn {
        width: auto;
        flex: 1;
    }
    
    /* Forms */
    .form-control-mobile {
        font-size: 1rem;
    }
    
    /* Modal */
    .modal-mobile .modal-dialog {
        margin: 1.75rem auto;
        min-height: auto;
        align-items: center;
    }
    
    .modal-mobile .modal-content {
        border-radius: var(--border-radius-lg);
    }
    
    /* Grid ajustes */
    .col-sm-auto-mobile {
        flex: 0 0 auto;
        width: auto;
    }
}

/* ===== MEDIUM (MD) - ≥768px ===== */
@media (min-width: 768px) {
    /* Mostrar colunas da tabela */
    .table .d-md-table-cell {
        display: table-cell !important;
    }
    
    /* Stack volta para tabela */
    .mobile-stack {
        display: table;
    }
    
    /* Dashboard layout */
    .dashboard-main {
        padding: 1.5rem;
    }
    
    /* Cards em grid */
    .card-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1.5rem;
    }
    
    /* Stats cards */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    /* Timeline responsiva */
    .timeline {
        padding-left: 3rem;
    }
    
    .timeline::before {
        left: 1.5rem;
    }
    
    .timeline-item::before {
        left: -2rem;
    }
    
    /* Sidebar layout */
    .has-sidebar {
        display: flex;
        gap: 1.5rem;
    }
    
    .sidebar {
        flex: 0 0 250px;
    }
    
    .main-content {
        flex: 1;
        min-width: 0;
    }
}

/* ===== LARGE (LG) - ≥992px ===== */
@media (min-width: 992px) {
    /* Container com mais espaçamento */
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    /* Dashboard aprimorado */
    .dashboard-main {
        padding: 2rem;
    }
    
    /* Cards maiores */
    .card-body {
        padding: 2rem;
    }
    
    /* Grid mais espaçado */
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 2rem;
    }
    
    /* Stats em linha */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
    
    /* Timeline mais espaçada */
    .timeline {
        padding-left: 4rem;
    }
    
    .timeline::before {
        left: 2rem;
    }
    
    .timeline-item::before {
        left: -2.5rem;
        width: 16px;
        height: 16px;
    }
    
    /* Sidebar maior */
    .sidebar {
        flex: 0 0 300px;
    }
    
    /* Tabelas com mais informações */
    .table .d-lg-table-cell {
        display: table-cell !important;
    }
    
    /* Modal maior */
    .modal-lg-custom {
        max-width: 900px;
    }
    
    /* Forms em colunas */
    .form-row {
        display: flex;
        gap: 1rem;
    }
    
    .form-row .form-group {
        flex: 1;
    }
}

/* ===== EXTRA LARGE (XL) - ≥1200px ===== */
@media (min-width: 1200px) {
    /* Container ainda maior */
    .container-fluid {
        max-width: 1140px;
        margin: 0 auto;
    }
    
    /* Dashboard com layout fixo */
    .dashboard-layout {
        display: grid;
        grid-template-columns: 300px 1fr;
        gap: 2rem;
        min-height: 100vh;
    }
    
    .dashboard-sidebar {
        position: sticky;
        top: 90px;
        height: fit-content;
    }
    
    /* Cards em grid otimizado */
    .card-grid-xl {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    /* Stats em 5 colunas */
    .stats-grid-xl {
        grid-template-columns: repeat(5, 1fr);
    }
    
    /* Tabela com todas as colunas */
    .table .d-xl-table-cell {
        display: table-cell !important;
    }
    
    /* Modal extra grande */
    .modal-xl-custom {
        max-width: 1200px;
    }
}

/* ===== XXL - ≥1400px ===== */
@media (min-width: 1400px) {
    /* Container para telas muito grandes */
    .container-fluid {
        max-width: 1320px;
    }
    
    /* Grid com mais colunas */
    .card-grid-xxl {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Stats em 6 colunas */
    .stats-grid-xxl {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ===== ORIENTAÇÃO ===== */

/* Landscape em tablets */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .dashboard-main {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Portrait em tablets */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== UTILIDADES RESPONSIVAS ===== */

/* Espaçamento responsivo */
@media (max-width: 767px) {
    .p-md-0 {
        padding: 0 !important;
    }
    
    .m-md-0 {
        margin: 0 !important;
    }
    
    .px-mobile-0 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .mx-mobile-0 {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Texto responsivo */
@media (max-width: 576px) {
    .display-1 {
        font-size: 2.5rem;
    }
    
    .display-2 {
        font-size: 2rem;
    }
    
    .display-3 {
        font-size: 1.75rem;
    }
    
    .display-4 {
        font-size: 1.5rem;
    }
    
    .display-5 {
        font-size: 1.25rem;
    }
    
    .lead {
        font-size: 1rem;
    }
}

/* ===== COMPONENTES RESPONSIVOS ESPECÍFICOS ===== */

/* Calendário responsivo */
@media (max-width: 768px) {
    .calendar-grid {
        font-size: 0.875rem;
    }
    
    .calendar-day {
        padding: 0.25rem;
    }
    
    .calendar-event {
        font-size: 0.75rem;
        padding: 0.125rem 0.25rem;
    }
}

/* Chat responsivo */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 200px);
    }
    
    .chat-input {
        padding: 0.5rem;
    }
    
    .chat-message {
        max-width: 85%;
    }
}

/* Upload de arquivos responsivo */
@media (max-width: 768px) {
    .file-upload-area {
        min-height: 150px;
    }
    
    .file-preview {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 0.5rem;
    }
}

/* Gráficos responsivos */
@media (max-width: 768px) {
    .chart-container {
        height: 250px !important;
    }
    
    .chart-legend {
        font-size: 0.75rem;
    }
}

/* ===== PRINT RESPONSIVO ===== */
@media print {
    .container-fluid {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .btn,
    .navbar,
    .sidebar {
        display: none !important;
    }
    
    .table {
        font-size: 12pt;
    }
    
    .table th,
    .table td {
        padding: 0.25rem;
    }
}

/* ===== ACESSIBILIDADE RESPONSIVA ===== */

/* Aumentar áreas de toque em mobile */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Melhor contraste em telas pequenas */
@media (max-width: 576px) {
    .text-muted {
        color: #495057 !important;
    }
    
    .form-control::placeholder {
        color: #6c757d;
    }
}

/* ===== DARK MODE RESPONSIVO ===== */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        .dark-mode .navbar {
            background-color: #000 !important;
        }
        
        .dark-mode .card {
            background-color: #1a1a1a;
        }
        
        .dark-mode .mobile-stack-item {
            border-bottom-color: #404040;
        }
    }
}

/* ===== PERFORMANCE ===== */

/* Reduzir animações em dispositivos com pouca bateria */
@media (prefers-reduced-motion: reduce) {
    .animate-fade-in,
    .animate-slide-in-left,
    .animate-slide-in-right,
    .animate-bounce-in {
        animation: none;
    }
    
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Otimizações para conexões lentas */
@media (max-width: 768px) and (prefers-reduced-data: reduce) {
    .hero-image img {
        display: none;
    }
    
    .bg-gradient-primary,
    .bg-gradient-success,
    .bg-gradient-info,
    .bg-gradient-warning,
    .bg-gradient-danger {
        background: var(--primary-color);
    }
}