:root {
    --primary-color: #008d88;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    font-size: 0.95rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 48px;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    overflow-y: auto;
}

.sidebar .nav-link {
    font-weight: 500;
    color: #333;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
    color: #008d88;
    background-color: rgba(0, 141, 136, 0.1);
}

.sidebar .nav-link.active {
    color: #008d88;
    background-color: rgba(0, 141, 136, 0.15);
    border-left: 3px solid #008d88;
}

.sidebar .nav-link i {
    margin-right: 8px;
    font-size: 1.1rem;
}

/* Cards Dashboard */
.stat-card {
    border-left: 4px solid;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card.primary {
    border-left-color: #008d88;
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.7;
}

/* Tables */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table thead {
    background-color: var(--primary-color);
    color: white;
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Action Buttons */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    margin: 0 2px;
}

/* Photo Upload Preview */
.photo-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 10px;
    border: 2px solid #dee2e6;
}

/* Procedure Photos */
.procedure-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.procedure-photo-item {
    position: relative;
}

.procedure-photo-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: transform 0.2s;
}

.procedure-photo-item img:hover {
    transform: scale(1.05);
}

/* Alert Badge */
.alert-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    padding: 3px 6px;
    font-size: 0.75rem;
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
    .sidebar {
        position: relative;
        top: 0;
    }
    
    main {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }
    
    .table-responsive {
        font-size: 0.85rem;
    }
    
    .btn-action {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    
    /* Header mobile */
    .navbar-brand {
        font-size: 1rem !important;
    }
    
    /* Cards mobile */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Botões mobile */
    .btn-toolbar {
        margin-bottom: 0.5rem !important;
    }
    
    /* Página títulos mobile */
    .h2 {
        font-size: 1.5rem;
    }
    
    /* Offcanvas menu styling */
    .offcanvas .nav-link {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        border-bottom: 1px solid #dee2e6;
    }
    
    .offcanvas .nav-link i {
        margin-right: 10px;
        font-size: 1.2rem;
    }
    
    .offcanvas .nav-link.active {
        background-color: rgba(0, 141, 136, 0.1);
        color: #008d88;
        border-left: 4px solid #008d88;
    }
    
    /* Remove padding extra em mobile */
    .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Ajustar alertas mobile */
    .alert {
        margin: 0.5rem;
        font-size: 0.9rem;
    }
}

/* Offcanvas customization */
.offcanvas {
    width: 280px !important;
}

.offcanvas-header {
    padding: 1.5rem;
}

.offcanvas-body {
    padding: 0;
}

.offcanvas .nav-link {
    color: #333;
    transition: all 0.3s;
}

.offcanvas .nav-link:hover {
    background-color: rgba(0, 141, 136, 0.05);
}

/* Botões de Acesso Rápido */
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.btn-lg:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-lg i {
    margin-right: 8px;
    font-size: 1.2rem;
}

/* Mobile - Botões de acesso rápido em grid */
@media (max-width: 767.98px) {
    .btn-lg {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .d-grid {
        gap: 0.5rem !important;
    }
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    background-color: var(--primary-color);
    color: white;
    border-radius: 15px 15px 0 0;
    padding: 2rem;
    text-align: center;
}

.login-header i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    margin-left: 0.5rem;
}

/* Forçar scroll horizontal no mobile */
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    width: 100% !important;
}

.dataTables_wrapper .table-responsive {
    overflow-x: auto !important;
}

/* Garantir que a tabela não quebre */
.dataTables_wrapper table {
    width: 100% !important;
    min-width: 800px; /* Largura mínima para forçar scroll */
}

/* Indicador de scroll no mobile */
.dataTables_wrapper .table-responsive::after {
    content: "← Arraste para ver mais →";
    display: none;
    position: sticky;
    right: 0;
    bottom: 0;
    background: rgba(0, 141, 136, 0.9);
    color: white;
    padding: 8px 15px;
    font-size: 12px;
    border-radius: 4px 0 0 0;
    text-align: center;
    z-index: 10;
}

/* Melhorar scroll no mobile */
@media (max-width: 767.98px) {
    .dataTables_wrapper {
        overflow-x: auto !important;
    }
    
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 4px;
        margin-bottom: 1rem;
        position: relative;
    }
    
    .dataTables_wrapper table {
        min-width: 900px; /* Forçar scroll horizontal */
        margin-bottom: 0 !important;
    }
    
    /* Mostrar indicador de scroll */
    .dataTables_wrapper .table-responsive::after {
        display: block;
    }
    
    /* Remover responsive mode do DataTables no mobile */
    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
        display: none !important;
    }
    
    /* Melhorar aparência dos botões no mobile */
    .btn-action {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Barra de scroll mais visível */
    .table-responsive::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #008d88;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: #006d68;
    }
}

/* Select2 Customization */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
    border: 1px solid #ced4da;
}

.select2-container--bootstrap-5 .select2-selection--single {
    padding: 0.375rem 0.75rem;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: #ced4da;
}

.select2-container--bootstrap-5 .select2-search__field {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    footer,
    .btn,
    .no-print {
        display: none !important;
    }
    
    main {
        margin: 0 !important;
        padding: 0 !important;
    }
}