body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
}

.hidden {
    display: none !important;
}

.desligamentos-wrapper {
    padding: 20px;
    box-sizing: border-box;
    max-width: 1400px;
    margin: 20px auto;
}

.main-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: #004076;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.filters-container {
    background-color: transparent;
    border-radius: 12px;
    box-shadow: none;
    padding: 30px;
    margin-bottom: 10px;
    display: flex;
    gap: 20px;
    align-items: end;
    flex-wrap: wrap;
    flex-direction: row; /* FORÇA OS FILTROS FICAREM LADO A LADO */
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    flex: 1;
}

.filter-label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

.municipios-dropdown,
.data-input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #e1e5e9;
    background-color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.municipios-dropdown:focus,
.data-input:focus {
    outline: none;
    border-color: #004076;
    box-shadow: 0 0 0 3px rgba(0, 64, 118, 0.1);
}

.buscar-btn {
    background: linear-gradient(135deg, #004076, #0056a3);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 64, 118, 0.3);
    min-width: 120px;
}

.buscar-btn:hover {
    background: linear-gradient(135deg, #0056a3, #004076);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 64, 118, 0.4);
}

.buscar-btn:active {
    transform: translateY(0);
}

.desligamentos-container {
    background-color: transparent;
    border-radius: 12px;
    box-shadow: none;
    padding: 30px;
    min-height: 400px;
}

.desligamentos-empty {
    text-align: center;
    color: #888;
    padding: 60px 20px;
    background-color: transparent;
    border-radius: 12px;
    border: none;
    font-size: 1.1rem;
}

.desligamentos-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.desligamento-card {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    border-radius: 12px;
    box-shadow: 0 4-12px rgba(0, 0, 0, 0.08);
    padding: clamp(12px, 2.5vw, 18px);
    border-left: 5px solid #004076;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
}

.desligamento-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #004076, #0056a3, #004076);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.desligamento-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.desligamento-card:hover::before {
    opacity: 1;
}

.desligamento-card-title {
    font-size: clamp(1rem, 4vw, 1.4rem);
    font-weight: 700;
    color: #004076;
    margin-bottom: 8px;
    line-height: 1.3;
    width: 100%;
}

.desligamento-card-datetime {
    display: flex;
    flex-direction: column !important; /* FORÇA O LAYOUT VERTICAL EM TODAS AS ORIENTAÇÕES */
    align-items: flex-start;
    margin-bottom: 8px;
    width: 100%;
    gap: 5px; /* Espaçamento entre data e horário */
}

.desligamento-card-date {
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    margin-bottom: 0; /* Remove margem para usar gap do container */
    font-weight: 600;
    color: #004076;
}

.desligamento-card-date::before {
    content: '📅';
    font-size: 1rem;
    flex-shrink: 0;
    margin-right: 4px;
}

.desligamento-card-time {
    font-size: 1.1rem;
    color: #28a745;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: normal;
    flex-shrink: 0;
    width: 100%;
    margin-top: 0; /* Remove margem para usar gap do container */
}

.desligamento-card-time::before {
    content: '🕒';
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-right: 4px;
}

.desligamento-card-detail {
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    color: #666;
    margin-bottom: 2px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
}

.desligamento-card-detail strong {
    color: #333;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    margin-right: 4px;
}

.desligamento-card-address {
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    color: #666;
    margin-top: 2px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: left;
    width: 100%;
}

.desligamento-card-address strong {
    display: inline;
    color: #333;
    font-weight: 600;
    margin-bottom: 0;
    margin-right: 4px;
}

.desligamento-card-detail:nth-of-type(3)::before {
    content: '';
    font-size: 1rem;
    flex-shrink: 0;
    margin-right: 4px;
}

.desligamento-card-detail:nth-of-type(4)::before {
    content: '';
    font-size: 1rem;
}

.loading {
    text-align: center;
    padding: 40px;
    font-style: italic;
    color: #888;
    font-size: 1.1rem;
}

.error-message {
    text-align: center;
    padding: 20px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 1rem;
}

/* Paginação - Estilos Corrigidos */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.pagination-controls button {
    background: linear-gradient(135deg, #0056b3, #004080);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
}

.pagination-controls button:hover {
    background: linear-gradient(135deg, #004080, #0056b3);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 64, 128, 0.4);
}

.pagination-controls button:active {
    transform: translateY(0);
}

.pagination-controls button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Regra dedicada apenas para o contador de páginas */
#pageInfo {
    font-weight: bold;
    color: #004076;
    font-size: 1rem;
    background-color: #e0f2f7;
    padding: 5px 10px;
    border-radius: 5px;
}

/* --- OTIMIZAÇÕES ESPECÍFICAS PARA TABLETS --- */

/* TABLETS EM ORIENTAÇÃO VERTICAL (PORTRAIT) - 2 COLUNAS */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .desligamentos-wrapper {
        padding: 25px;
        margin: 15px auto;
    }

    .main-title {
        font-size: 2.4rem;
        margin-bottom: 35px;
    }

    .filters-container {
        padding: 35px;
        gap: 25px;
        justify-content: center;
        flex-direction: row; /* LADO A LADO EM TABLETS VERTICAL */
    }

    .filter-group {
        min-width: 250px;
        max-width: 300px;
    }

    .municipios-dropdown,
    .data-input {
        padding: 16px;
        font-size: 1.2rem;
        min-height: 52px;
    }

    .buscar-btn {
        padding: 16px 32px;
        font-size: 1.1rem;
        min-width: 140px;
        min-height: 52px;
    }

    .desligamentos-container {
        padding: 35px;
    }

    /* 2 COLUNAS EM VERTICAL */
    .desligamentos-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
        margin-top: 25px;
    }

    .desligamento-card {
        padding: 18px;
        min-height: 260px;
    }

    .desligamento-card-title {
        font-size: 1.35rem;
        margin-bottom: 12px;
    }

    .desligamento-card-datetime {
        margin-bottom: 10px;
        gap: 12px;
        flex-direction: column;
        align-items: flex-start;
    }

    .desligamento-card-date,
    .desligamento-card-time {
        font-size: 1.1rem;
        width: 100%;
        justify-content: flex-start;
    }

    .desligamento-card-detail,
    .desligamento-card-address {
        font-size: 1.05rem;
        margin-bottom: 4px;
        line-height: 1.5;
        text-align: left;
    }

    .pagination-controls {
        gap: 20px;
        margin-top: 35px;
        padding-top: 25px;
    }

    .pagination-controls button {
        padding: 16px 28px;
        font-size: 1.1rem;
        min-height: 52px;
        min-width: 130px;
    }

    #pageInfo {
        font-size: 1.1rem;
    }
}

/* TABLETS EM ORIENTAÇÃO HORIZONTAL (LANDSCAPE) - 3 COLUNAS */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .desligamentos-wrapper {
        padding: 20px;
        margin: 10px auto;
    }

    .main-title {
        font-size: 2.1rem;
        margin-bottom: 25px;
    }

    .filters-container {
        padding: 25px;
        gap: 20px;
        flex-direction: row; /* HORIZONTAL PARA OS FILTROS EM LANDSCAPE */
        justify-content: space-between;
        align-items: end;
    }

    .filter-group {
        min-width: 200px;
        flex: 1;
        max-width: 250px;
    }

    .municipios-dropdown,
    .data-input {
        padding: 14px;
        font-size: 1.1rem;
        min-height: 48px;
    }

    .buscar-btn {
        padding: 14px 28px;
        font-size: 1rem;
        min-width: 120px;
        min-height: 48px;
        flex-shrink: 0;
    }

    .desligamentos-container {
        padding: 25px;
    }

    /* 3 COLUNAS EM HORIZONTAL */
    .desligamentos-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        margin-top: 20px;
    }

    .desligamento-card {
        padding: 16px;
        min-height: 240px;
    }

    .desligamento-card-title {
        font-size: 1.25rem;
        margin-bottom: 10px;
    }

    .desligamento-card-datetime {
        margin-bottom: 8px;
        gap: 5px;
        flex-direction: column !important; /* FORÇA VERTICAL MESMO EM HORIZONTAL */
        align-items: flex-start !important;
    }

    .desligamento-card-date,
    .desligamento-card-time {
        font-size: 1rem;
        width: 100% !important;
        justify-content: flex-start !important;
    }

    .desligamento-card-detail,
    .desligamento-card-address {
        font-size: 1rem;
        margin-bottom: 3px;
        line-height: 1.4;
        text-align: left;
    }
}

/* iPad específico (768px) - SEMPRE 2 COLUNAS EM PORTRAIT */
@media (width: 768px) and (orientation: portrait) {
    .desligamentos-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px;
    }

    .desligamento-card {
        min-height: 250px;
        padding: 18px;
    }
}

/* iPad específico (768px) - SEMPRE 3 COLUNAS EM LANDSCAPE */
@media (width: 768px) and (orientation: landscape) {
    .desligamentos-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 14px;
    }

    .desligamento-card {
        min-height: 220px;
        padding: 16px;
    }
}

/* iPad Pro específico (1024px) - 2 COLUNAS EM PORTRAIT */
@media (width: 1024px) and (orientation: portrait) {
    .desligamentos-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }

    .desligamento-card {
        min-height: 280px;
        padding: 20px;
    }

    .main-title {
        font-size: 2.6rem;
    }
}

/* iPad Pro específico (1024px) - 3 COLUNAS EM LANDSCAPE */
@media (width: 1024px) and (orientation: landscape) {
    .desligamentos-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px;
    }

    .desligamento-card {
        min-height: 250px;
        padding: 18px;
    }

    .main-title {
        font-size: 2.3rem;
    }
}

/* Ajustes para dispositivos touch em tablets */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) and (max-width: 1024px) {
    .municipios-dropdown,
    .data-input,
    .buscar-btn,
    .pagination-controls button {
        min-height: 48px;
    }

    .desligamento-card:hover {
        transform: none;
    }

    .desligamento-card:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }

    .buscar-btn:hover,
    .pagination-controls button:hover {
        transform: none;
    }

    .buscar-btn:active,
    .pagination-controls button:active {
        transform: scale(0.95);
    }
}

/* Melhorias para tablets com telas de alta densidade */
@media (min-width: 768px) and (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 2) {
    .desligamento-card {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    }

    .desligamento-card:hover {
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.18);
    }

    .buscar-btn,
    .pagination-controls button {
        box-shadow: 0 6px 16px rgba(0, 64, 118, 0.4);
    }
}

/* Adaptação para celulares (final) */
@media (max-width: 767px) {
    .desligamentos-list {
        grid-template-columns: 1fr !important;
    }

    .filters-container {
        flex-direction: row; /* LADO A LADO MESMO EM CELULARES */
        align-items: stretch;
        gap: 15px;
        padding: 20px;
    }

    .filter-group {
        min-width: auto;
        flex: 1; /* CADA FILTRO OCUPA ESPAÇO IGUAL */
    }

    /* APENAS EM TELAS MUITO PEQUENAS (MENOS DE 480PX) OS FILTROS FICAM EM COLUNA */
    @media (max-width: 480px) {
        .filters-container {
            flex-direction: column !important;
        }
        
        .filter-group {
            flex: none;
        }
    }

    /* FORÇA LAYOUT VERTICAL PARA DATA E HORÁRIO EM CELULARES */
    .desligamento-card-datetime {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 5px !important;
        margin-bottom: 10px !important;
        width: 100% !important;
    }

    .desligamento-card-date {
        width: 100% !important;
        margin-bottom: 0 !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        color: #004076 !important;
    }

    .desligamento-card-time {
        width: 100% !important;
        margin-top: 0 !important;
        font-size: 1rem !important;
        color: #28a745 !important;
        font-weight: 600 !important;
    }

   .pagination-controls {
        flex-direction: column; /* Altera a direção para coluna */
        gap: 15px;
        align-items: center; /* Centraliza os itens horizontalmente */
    }
    .pagination-controls button,
    .pagination-controls span {
        width: auto !important; /* REMOVE A LARGURA 100% */
    }

    .pagination-controls button {
        padding: 12px 20px;
        min-width: 100px;
    }

    .pagination-controls button .btn-text {
        font-size: 1rem !important;
        display: inline-block !important;
        white-space: normal !important;
    }
}

/* Desktop (acima de 1024px) */
@media (min-width: 1025px) {
    .desligamentos-list {
        grid-template-columns: repeat(3, 1fr);
    }
}