/* ===== COMPONENTES REUTILIZÁVEIS ===== */

/* Reset de botões */
button {
    font-family: inherit;
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #2a5298;
    color: white;
    border-color: #2a5298;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1e3c72;
    border-color: #1e3c72;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #545b62;
    border-color: #545b62;
}

.btn-success {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

.btn-success:hover:not(:disabled) {
    background-color: #218838;
    border-color: #218838;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
    border-color: #c82333;
}

.btn-outline {
    background-color: transparent;
    color: #6c757d;
    border-color: #dee2e6;
}

.btn-outline:hover:not(:disabled) {
    background-color: #f8f9fa;
    color: #495057;
    border-color: #adb5bd;
}

/* Botões de ação pequenos */
.btn-action {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    margin: 0 2px;
}

.btn-edit {
    background-color: #17a2b8;
    color: white;
}

.btn-edit:hover {
    background-color: #138496;
}

.btn-view {
    background-color: #6c757d;
    color: white;
}

.btn-view:hover {
    background-color: #545b62;
}

.btn-delete {
    background-color: #dc3545;
    color: white;
}

.btn-delete:hover {
    background-color: #c82333;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 4px;
}

/* ===== LAYOUT DE PÁGINAS ===== */

/* Cabeçalho da página */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.page-title h2 {
    color: #2a5298;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title p {
    color: #6c757d;
    font-size: 14px;
    margin: 0;
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Cards de conteúdo */
.content-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    color: #495057;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

/* ===== FORMULÁRIOS ===== */

.form-container {
    max-width: 100%;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.col-md-12 { flex: 0 0 100%; }
.form-group.col-md-8 { flex: 0 0 66.666%; }
.form-group.col-md-6 { flex: 0 0 50%; }
.form-group.col-md-4 { flex: 0 0 33.333%; }
.form-group.col-md-3 { flex: 0 0 25%; }

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.form-label.required::after {
    content: " *";
    color: #dc3545;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: #fff;
}

.form-control:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.form-control.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 0;
    border-top: 1px solid #e9ecef;
    margin-top: 30px;
}

/* ===== TABELAS ===== */

.table-container {
    position: relative;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.table-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    color: #6c757d;
}

.table-loading i {
    font-size: 24px;
    margin-bottom: 10px;
    color: #2a5298;
}

/* Informações da unidade na tabela */
.unit-info strong {
    color: #2a5298;
    font-weight: 600;
}

.unit-info small {
    color: #6c757d;
    font-size: 12px;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
}

.status-inactive {
    background-color: #fff3cd;
    color: #856404;
}

/* Sem dados */
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.no-data i {
    font-size: 48px;
    margin-bottom: 20px;
    color: #adb5bd;
}

.no-data h4 {
    margin-bottom: 10px;
    color: #495057;
}

.no-data p {
    margin-bottom: 20px;
}

/* ===== PAGINAÇÃO ===== */

.table-pagination {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.pagination-controls .btn {
    padding: 6px 12px;
    font-size: 13px;
}

.pagination-dots {
    padding: 6px 8px;
    color: #6c757d;
}

.total-records {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
}

/* ===== FILTROS ===== */

.filters-section {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

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

.filter-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== MODAIS ===== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    margin: 0;
    color: #495057;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #495057;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 0 20px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== RELATÓRIOS ===== */

/* Grid de estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-icon.bg-primary { background-color: #2a5298; }
.stat-icon.bg-success { background-color: #28a745; }
.stat-icon.bg-warning { background-color: #ffc107; }
.stat-icon.bg-info { background-color: #17a2b8; }

.stat-content h3 {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 5px 0;
    color: #2a5298;
}

.stat-content p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

/* Grid de gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Barra de progresso */
.progress-bar {
    position: relative;
    background-color: #e9ecef;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: #495057;
}

/* ===== UTILITÁRIOS ===== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: #2a5298 !important; }
.text-secondary { color: #6c757d !important; }
.text-success { color: #28a745 !important; }
.text-danger { color: #dc3545 !important; }
.text-warning { color: #ffc107 !important; }
.text-info { color: #17a2b8 !important; }

.bg-primary { background-color: #2a5298 !important; }
.bg-secondary { background-color: #6c757d !important; }
.bg-success { background-color: #28a745 !important; }
.bg-danger { background-color: #dc3545 !important; }
.bg-warning { background-color: #ffc107 !important; }
.bg-info { background-color: #17a2b8 !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

/* ===== RESPONSIVIDADE ===== */

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .page-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-group.col-md-12,
    .form-group.col-md-8,
    .form-group.col-md-6,
    .form-group.col-md-4,
    .form-group.col-md-3 {
        flex: 0 0 100%;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-group {
        min-width: auto;
    }
    
    .filter-actions {
        justify-content: stretch;
    }
    
    .filter-actions .btn {
        flex: 1;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 2px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        gap: 3px;
    }
    
    .pagination-controls .btn {
        padding: 4px 8px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .card-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .card-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .modal-content {
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== ANIMAÇÕES ===== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.content-card {
    animation: fadeIn 0.3s ease;
}

.stat-card {
    animation: slideIn 0.3s ease;
}

/* Animação de loading */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spin {
    animation: spin 1s linear infinite;
}

/* ===== IMPRESSÃO ===== */

@media print {
    .page-actions,
    .filter-actions,
    .action-buttons,
    .card-actions,
    .btn {
        display: none !important;
    }
    
    .content-card {
        box-shadow: none;
        border: 1px solid #dee2e6;
        break-inside: avoid;
    }
    
    .page-header {
        border-bottom: 2px solid #000;
        margin-bottom: 20px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th {
        background-color: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
    }
}