:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #34495e;
    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html,
body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    display: block;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    color: var(--secondary-color);
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-item {
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.3s;
    color: white;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.menu-item:hover, .menu-item.active {
    background-color: rgba(255,255,255,0.1);
    text-decoration: none;
    color: white;
}

.menu-item i {
    width: 20px;
    text-align: center;
}

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-width: 0;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    transition: margin-left 0.3s, width 0.3s, max-width 0.3s;
}

.main-content > * {
    max-width: 100%;
    min-width: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
}

.header h1 {
    color: var(--primary-color);
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--dark-color);
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.card .value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.card.status-aguardando-auditoria { border-top: 4px solid var(--warning-color); }
.card.status-em-auditoria { border-top: 4px solid var(--secondary-color); }
.card.status-aguardando-correcao { border-top: 4px solid var(--danger-color); }
.card.status-aguardando-revisao { border-top: 4px solid #fd7e14; }
.card.status-entregue-ao-faturamento { border-top: 4px solid var(--success-color); }
.card.status-total { border-top: 4px solid var(--dark-color); }

.content-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 2rem;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.filter-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.filter-item select, .filter-item input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.table-container {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.table-container > table {
    width: max-content;
    min-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: var(--light-color);
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f9f9f9;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-aguardando-auditoria { background-color: #fff3cd; color: #856404; }
.status-em-auditoria { background-color: #d1ecf1; color: #0c5460; }
.status-aguardando-correcao { background-color: #f8d7da; color: #721c24; }
.status-aguardando-revisao { background-color: #ffeaa7; color: #856404; }
.status-entregue-ao-faturamento { background-color: #d4edda; color: #155724; }

.error-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.error-documentacao { background-color: #ffcccc; color: #990000; }
.error-registro { background-color: #ffddcc; color: #994400; }
.error-procedimento { background-color: #ffffcc; color: #666600; }
.error-codificacao { background-color: #ccffcc; color: #006600; }
.error-faturamento { background-color: #ccccff; color: #000099; }
.error-prazo { background-color: #ffccff; color: #990099; }

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #219653;
}

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

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-outline-primary {
    background-color: transparent;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
}

.btn-outline-primary:hover {
    background-color: var(--secondary-color);
    color: white;
}

.btn-outline-danger {
    background-color: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.quick-action {
    text-align: center;
    padding: 2rem 1rem;
}

.quick-action i {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.quick-action h4 {
    margin-bottom: 0.5rem;
}

.quick-action p {
    color: #666;
    margin-bottom: 1rem;
}

.patient-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

.patient-link:hover {
    text-decoration: underline;
    color: #2980b9;
}

footer {
    background-color: var(--dark-color);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    border-radius: 8px;
}

/* Modal Styles */
.modal-content {
    border-radius: 8px;
    border: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
}

/* Form Styles */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.form-control, .form-select {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-check {
    margin-bottom: 0.5rem;
}

.form-check-input:checked {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Alert Styles */
.alert {
    border: none;
    border-radius: 6px;
    padding: 1rem 1.5rem;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    
    .sidebar .menu-text {
        display: none;
    }
    
    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        max-width: calc(100% - 70px);
        min-width: 0;
        padding: 12px;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

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

.content-section {
    animation: fadeIn 0.5s ease-in-out;
}

/* Print Styles */
@media print {
    .sidebar, .header, footer, .btn {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .content-section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

.btn-group .btn {
    margin: 0 2px;
    border-radius: 4px;
}

.btn-group .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-group .btn {
    margin: 0 1px;
    border-radius: 4px;
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
}

.btn-group .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-group .btn-outline-primary:hover {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-group .btn-outline-success:hover {
    background-color: #198754;
    border-color: #198754;
}

.btn-group .btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
}

.btn-group .btn:hover i {
    color: white !important;
}

/* Garantir que os ícones fiquem centralizados */
.btn-group .btn i {
    font-size: 0.875rem;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================================
   CORREÇÃO DE LAYOUT: CONTEÚDO E TABELAS FORA DO MENU LATERAL
   ========================================================= */
.sidebar {
    top: 0;
    left: 0;
    z-index: 1000;
}

.main-content {
    box-sizing: border-box;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-width: 0;
    overflow-x: hidden;
}

.main-content .content-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.main-content .table-container,
.main-content .table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.main-content .table-container > table,
.main-content .table-responsive > table {
    min-width: 1180px;
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        max-width: calc(100% - 70px);
        min-width: 0;
        padding: 12px;
    }
}