:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --bg-color: #ffffff;
    --text-color: #212529;
    --border-color: #dee2e6;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --border-color: #404040;
    --light-color: #2d2d2d;
    --dark-color: #f8f9fa;
    --shadow: 0 0.125rem 0.25rem rgba(255, 255, 255, 0.075);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.card {
    background-color: var(--bg-color);
    border-color: var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

[data-theme="dark"] .card {
    background-color: var(--light-color);
}

.table {
    color: var(--text-color);
}

[data-theme="dark"] .table {
    --bs-table-bg: var(--light-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

/* Destacar nomes e textos importantes no dark mode */
[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    color: #ffffff !important;
    border-color: #404040;
}

[data-theme="dark"] .table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Melhorar contraste dos textos no dark mode */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
    color: #ffffff !important;
}

[data-theme="dark"] .navbar-brand {
    color: #ffffff !important;
}

[data-theme="dark"] .nav-link {
    color: #ffffff !important;
}

[data-theme="dark"] .nav-link:hover {
    color: var(--primary-color) !important;
}

[data-theme="dark"] .card-title {
    color: #ffffff !important;
}

[data-theme="dark"] .card-text {
    color: #e9ecef !important;
}

[data-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

.modal-content {
    background-color: var(--bg-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .modal-content {
    background-color: var(--light-color);
}

[data-theme="dark"] .modal-header {
    border-color: #404040;
}

[data-theme="dark"] .modal-footer {
    border-color: #404040;
}

[data-theme="dark"] .modal-title {
    color: #ffffff !important;
}

.form-control, .form-select {
    background-color: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--text-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

[data-theme="dark"] .form-label {
    color: #ffffff !important;
}

/* Melhorar botões no dark mode */
[data-theme="dark"] .btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

[data-theme="dark"] .btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: #ffffff;
}

[data-theme="dark"] .btn-outline-secondary {
    color: #6c757d;
    border-color: #6c757d;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #6c757d;
    color: #ffffff;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.card-body h4 {
    font-size: 2rem;
    font-weight: bold;
    margin: 0;
}

.card-body p {
    margin: 0;
    opacity: 0.8;
}

.table th {
    border-top: none;
    font-weight: 600;
}

.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal {
    backdrop-filter: blur(5px);
}

.table-responsive {
    border-radius: 0.375rem;
    overflow: hidden;
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .card-body h4 {
        font-size: 1.5rem;
    }
    
    .btn {
        font-size: 0.875rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    /* Scroll horizontal para tabelas no modo responsivo */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    .table {
        min-width: 600px; /* Largura mínima para manter todas as colunas visíveis */
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        white-space: nowrap;
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Garantir que as colunas de valores tenham largura adequada */
    .table th:nth-child(4), /* Quantidade */
    .table th:nth-child(5), /* Total Calculado */
    .table th:nth-child(6), /* Ações */
    .table td:nth-child(4),
    .table td:nth-child(5),
    .table td:nth-child(6) {
        min-width: 100px;
        text-align: center;
    }
    
    /* Estilizar o total geral */
    .table tfoot th {
        font-weight: bold;
        background-color: var(--dark-color);
        color: white;
        position: sticky;
        bottom: 0;
    }
}

/* Para telas muito pequenas */
@media (max-width: 480px) {
    .table {
        min-width: 550px;
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 0.4rem;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }
    
    /* Ajustar largura das colunas de valores */
    .table th:nth-child(4),
    .table th:nth-child(5),
    .table td:nth-child(4),
    .table td:nth-child(5) {
        min-width: 80px;
        text-align: right;
    }
    
    /* Garantir que o total geral seja visível */
    .table tfoot th {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }
}

/* Estilos adicionais para telas muito pequenas */
@media (max-width: 480px) {
    .table-responsive {
        font-size: 0.75rem;
    }
    
    .table th,
    .table td {
        padding: 0.4rem 0.2rem;
    }
    
    /* Reduzir ainda mais o padding para caber melhor */
    .table tfoot th {
        font-size: 0.7rem;
        padding: 0.4rem 0.2rem;
    }
    
    /* Ajustar badges */
    .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section.active {
    animation: fadeIn 0.3s ease;
}

/* Loading spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

[data-theme="dark"] .spinner {
    border: 4px solid #404040;
    border-top: 4px solid var(--primary-color);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}