/* Configurações globais e variáveis de tema */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --bg-body: #f4f6f9;
    --bg-card: #ffffff;
    --text-color: #333333;
    --text-secondary: #555555;
    --border-color: #eeeeee;
    --table-header-bg: #f8f9fa;
    --input-bg: #ffffff;
    --input-border: #cccccc;
}

[data-theme="dark"] {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #333333;
    --table-header-bg: #2a2a2a;
    --input-bg: #2b2b2b;
    --input-border: #444444;
}

body {
    background-color: var(--bg-body);
    color: var(--text-color);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* TELA DE LOGIN */

.login-header-switch {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
}

.login-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.25rem;
    box-sizing: border-box;
    background-color: var(--bg-body);
}

.login-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 25rem;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 1.25rem;
}

.logo-area img {
    width: 155px;
    max-width: 60%;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto 0.5rem auto;
}

.logo-area h2 {
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

#loginForm #btnLogin {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background-color: #0056b3;
    color: #ffffff;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
}

#loginForm #btnLogin:hover {
    background-color: #004085;
}

.error-message {
    color: #d9534f;
    background-color: #fdf7f7;
    border: 1px solid #f8b4b4;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    text-align: center;
    display: none;
    box-sizing: border-box;
}

.error-message.ativo {
    display: block;
}

/* CAMPOS DE FORMULÁRIO E INPUTS GLOBAIS */
.input-group {
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.input-group label {
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    height: 38px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.375rem;
    font-size: 0.95rem;
    outline: none;
    background-color: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box;
    transition: border-color 0.2s, background-color 0.3s;
}

textarea {
    height: auto;
    padding: 0.65rem 0.75rem;
}

input:focus, 
select:focus,
textarea:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.15);
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: var(--input-bg) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--input-border) !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover, 
[data-theme="dark"] input:-webkit-autofill:focus, 
[data-theme="dark"] input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--input-bg) inset !important;
    -webkit-text-fill-color: var(--text-color) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Linha de Pagamento Liberado e Status */
.payment-status-row {
    display: flex;
    gap: 10px;
    margin-bottom: 0.75rem;
    width: 100%;
}

.payment-status-row .input-group {
    flex: 1;
    margin-bottom: 0 !important;
}

.custom-checkbox-container {
    display: flex;
    align-items: center;
    height: 38px;
    padding: 0 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.375rem;
    background-color: var(--input-bg);
    cursor: pointer;
    user-select: none;
    margin: 0;
    transition: border-color 0.2s, background-color 0.2s;
}

.custom-checkbox-container:hover {
    border-color: #0056b3;
}

.custom-checkbox-container input[type="checkbox"] {
    width: 1.1rem !important;
    height: 1.1rem !important;
    margin: 0 0.6rem 0 0 !important;
    accent-color: #0056b3;
    cursor: pointer;
}

.custom-checkbox-container span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1;
}

/* Centralização do texto no Drag & Drop */
.drop-zone {
    border: 2px dashed var(--input-border) !important;
    border-radius: 6px;
    padding: 0.5rem;
    text-align: center;
    background-color: var(--table-header-bg) !important;
    color: var(--text-secondary) !important;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #0056b3 !important;
    background-color: rgba(0, 86, 179, 0.15) !important;
    color: var(--text-color) !important;
}

.drop-zone p {
    font-size: 0.85rem;
    margin: 0;
}

/* Linha de upload de comprovantes */
.upload-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 0.8rem;
}

.upload-row .input-group input[type="text"] {
    height: 48px;
}

.upload-row .drop-zone {
    height: 48px;
    margin-top: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem !important;
}

/* Campos dinâmicos nos Modais (+ e -) */
.dynamic-input-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    width: 100%;
}

.dynamic-input-row > div {
    display: flex;
    gap: 6px;
    align-items: stretch;
    width: 100%;
}

.dynamic-input-row input {
    margin-bottom: 0 !important;
}

.btn-add, .btn-remove {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    flex-shrink: 0;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-add {
    background-color: #0056b3;
    color: #ffffff;
}

.btn-add:hover {
    filter: brightness(1.2);
}

.btn-remove {
    background-color: #dc3545;
    color: #ffffff;
}

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

/* Botões gerais */
button {
    width: 100%;
    padding: 0.75rem;
    background-color: #0056b3;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

button:hover {
    background-color: #004085;
}

/* PAINEL PRINCIPAL & NAVBAR */
.dashboard-container {
    width: 98%;
    max-width: 106.25rem;
    margin: 0 auto;
    padding: 1rem 0.5rem;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.625rem rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
    transition: background-color 0.3s;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.header-logo h1 {
    font-size: 1.35rem;
    color: var(--text-color);
    margin: 0;
    line-height: 1;
}

.nav-logo {
    height: 3.125rem !important;
    width: 9.375rem !important;
    object-fit: cover !important;
    object-position: center !important;
    border-radius: 0.25rem;
    display: block;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

/* Botão de alternância de tema */
.theme-switch {
    position: relative !important;
    display: inline-block !important;
    width: 3.75rem !important;
    min-width: 3.75rem !important;
    height: 2rem !important;
    cursor: pointer;
    margin: 0;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.theme-switch .slider {
    position: absolute;
    inset: 0;
    background-color: #2c2c2c;
    border-radius: 2.125rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.375rem;
    box-shadow: inset 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.theme-switch .icon {
    width: 1rem;
    height: 1rem;
    z-index: 1;
}

.theme-switch .sun-icon { color: #ffd700; }
.theme-switch .moon-icon { color: #e0e0e0; }

.theme-switch .thumb {
    position: absolute;
    height: 1.5rem;
    width: 1.5rem;
    left: 0.25rem;
    bottom: 0.25rem;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0.125rem 0.3125rem rgba(0,0,0,0.3);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.theme-switch input:checked + .slider .thumb {
    transform: translateX(1.75rem);
}

[data-theme="dark"] .theme-switch .slider {
    background-color: #3a3a3c;
}

/* Botões de ação do topo */
.btn-primary {
    width: auto;
    padding: 0.6rem 1.2rem;
    background-color: #28a745;
    font-size: 0.9rem;
    border-radius: 0.375rem;
}

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

.btn-secondary { 
    background-color: #34495e; 
    width: auto;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 0.375rem;
}
.btn-secondary:hover { background-color: #2c3e50; }

.btn-logout {
    width: auto;
    background-color: #dc3545;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 0.375rem;
}

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

/* TABELAS SINCRONIZADAS E ALINHADAS COM LARGURAS FIXAS */
.table-container {
    background: var(--bg-card);
    padding: 1.8rem 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.625rem rgba(0,0,0,0.05);
    overflow-x: auto;
    transition: background-color 0.3s;
}

.table-container h2,
.modal-content h3 {
    text-align: center;
    margin-bottom: 1.2rem;
    color: var(--text-color);
}

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

th, td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    vertical-align: middle;
    color: var(--text-color);
}

th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* LARGURAS EXATAS DAS 9 COLUNAS */
table th:nth-child(1), table td:nth-child(1) { width: 85px; text-align: left; }
table th:nth-child(2), table td:nth-child(2) { width: 13%; text-align: left; }
table th:nth-child(3), table td:nth-child(3) { width: 18%; text-align: left; word-break: break-word; }
table th:nth-child(4), table td:nth-child(4) { width: 18%; text-align: left; word-break: break-word; }
table th:nth-child(5), table td:nth-child(5) { width: 90px; text-align: left; }
table th:nth-child(6), table td:nth-child(6) { width: 13%; text-align: left; }
table th:nth-child(7), table td:nth-child(7) { width: 130px; text-align: center; }
table th:nth-child(8), table td:nth-child(8) { width: 95px; text-align: center; }
table th:nth-child(9), table td:nth-child(9) { width: 230px; text-align: center; }

/* CÉLULA E BOTÕES DE AÇÃO RIGIDAMENTE ALINHADOS */
.actions-cell {
    width: 230px !important;
    text-align: center !important;
    white-space: nowrap !important;
}

.actions-cell .btn-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action {
    width: 68px !important;
    min-width: 68px !important;
    max-width: 68px !important;
    height: 28px !important;
    padding: 0 4px !important;
    margin: 0 !important;
    font-size: 0.72rem !important;
    font-weight: 600;
    border: none;
    border-radius: 0.25rem;
    color: #ffffff;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: opacity 0.2s;
}

.btn-action:hover {
    opacity: 0.85;
}

.status-badge {
    display: inline-block;
    padding: 0.35rem 0.6rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
    background: var(--table-header-bg);
    color: var(--text-color);
    white-space: nowrap;
}

.btn-obs {
    background-color: var(--table-header-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-obs:hover { background-color: var(--input-border); }

/* Seção retrátil do histórico */
.section-header {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin: 0 !important;
    line-height: 1;
}

.toggle-icon {
    display: inline-block;
    font-size: 0.8rem;
    margin-left: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    vertical-align: middle;
}

.toggle-icon.collapsed {
    transform: rotate(-180deg);
}

.collapsible-content {
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out, margin 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

/* MODAIS */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#obsModal { z-index: 10001 !important; }

.modal-content {
    background: var(--bg-card);
    color: var(--text-color);
    padding: 1.75rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 48rem;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0.25rem 0.9375rem rgba(0,0,0,0.3);
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.modal-table td, .modal-table th {
    padding: 0.6rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.btn-finalizar {
    background-color: #28a745;
    color: #ffffff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, filter 0.2s;
}

.btn-finalizar:hover {
    background-color: #218838;
}

.btn-submit {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: auto;
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background-color: #004085;
}

.btn-cancel {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: auto;
    transition: background-color 0.2s;
}

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