/* Sistema de Upload Metabase - v2.8.0 - Identidade Visual Saúde Digital */

:root {
    /* Paleta Oficial Saúde Digital */
    --azul-principal: #337ab7;
    --azul-botao: #478fcd;
    --cinza-fundo: #f2f2f2;
    --cinza-texto: #555;
    --preto-texto: #222;
    --branco: #ffffff;
    --erro: #cc0000;
    --sucesso: #28a745;
    --aviso: #ffc107;
    
    /* Aliases para compatibilidade */
    --primary: var(--azul-principal);
    --primary-hover: #2868a0;
    --secondary: var(--cinza-texto);
    --success: var(--sucesso);
    --error: var(--erro);
    --bg: var(--cinza-fundo);
    --card-bg: var(--branco);
    --border: #ddd;
    --text: var(--preto-texto);
    --text-light: var(--cinza-texto);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', 'Segoe UI', sans-serif;
    background: var(--cinza-fundo);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

.top-bar {
    background: var(--azul-principal);
    color: var(--branco);
    padding: 15px 40px;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    height: 80px;
}

.logo-header {
    height: 60px;
}

.right-group {
    text-align: right;
}

.right div:first-child {
    font-size: 18px;
    font-weight: 700;
    color: var(--branco);
}

.right div:last-child {
    font-size: 14px;
    color: var(--branco);
    opacity: 0.9;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h1 {
    font-size: 28px;
    color: var(--azul-principal);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.card h2 {
    font-size: 20px;
    color: var(--azul-principal);
    margin: 30px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
}

h2 {
    font-size: 22px;
    color: var(--azul-principal);
    margin-bottom: 20px;
    font-weight: 600;
}

.section {
    background: var(--branco);
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* Upload Area */
.upload-area {
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg);
}

.upload-area:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-area.dragover {
    border-color: var(--primary);
    background: #dbeafe;
    transform: scale(1.02);
}

.upload-area i {
    font-size: 64px;
    color: var(--primary);
    margin-bottom: 20px;
}

.upload-area p {
    font-size: 18px;
    color: var(--text);
    margin: 10px 0;
}

.upload-area small {
    color: var(--text-light);
}

#fileInfo {
    background: #eff6ff;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

#fileInfo p {
    margin: 5px 0;
    color: var(--text);
}

/* Preview Table */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.preview-table th {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.preview-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-table tr:hover {
    background: var(--bg);
}

/* Column Config */
.column-config {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    background: var(--bg);
}

.column-config-item {
    display: grid;
    grid-template-columns: 2fr 1.5fr auto;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.2s;
    align-items: center;
}

.column-config-item:hover {
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.column-header {
    display: flex;
    gap: 8px;
    align-items: center;
}

.column-name-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.column-name-input:focus {
    outline: none;
    border-color: var(--primary);
}

.column-type-select {
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background: white;
    transition: all 0.3s;
}

.column-type-select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-icon {
    background: var(--bg);
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s;
}

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

/* Form Groups */
.form-group {
    margin: 25px 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    font-size: 15px;
}

.input-field {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.radio-label:hover {
    background: #e0e7ff;
}

.radio-label input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.radio-label span {
    font-size: 14px;
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--azul-principal);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(51, 122, 183, 0.3);
}

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

.btn-secondary:hover {
    background: #475569;
}

.btn-info {
    background: var(--azul-botao);
    color: white;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-info:hover {
    background: #0891b2;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 17px;
    margin-top: 30px;
}

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

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--bg);
    border-radius: 15px;
    overflow: hidden;
    margin: 20px 0;
    border: 2px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #06b6d4);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

#progressText {
    text-align: center;
    color: var(--text);
    font-size: 16px;
    margin-top: 10px;
}

/* Alerts */
.alert {
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.alert-success {
    background: var(--sucesso);
    color: white;
    border: none;
}

.alert-error {
    background: var(--erro);
    color: white;
    border: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h3 {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--text);
}

.modal-content p {
    color: var(--text-light);
    margin-bottom: 20px;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 25px;
    transition: all 0.3s;
}

.modal-content input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-buttons .btn {
    flex: 1;
}

/* Scrollbar personalizada */
.column-config::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.column-config::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

.column-config::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

.column-config::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Colunas Customizadas */
.custom-columns-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.custom-column-item {
    display: grid;
    grid-template-columns: 2fr 2fr 40px;
    gap: 10px;
    padding: 10px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
    align-items: center;
}

.custom-column-item input {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.btn-remove {
    background: var(--erro);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background: #a00;
}

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

.btn-success:hover {
    background: #218838;
}

/* Checkbox Anonimizar */
.checkbox-anonimizar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--cinza-texto);
    cursor: pointer;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.checkbox-anonimizar:hover {
    background: #e8f5e9;
    color: var(--sucesso);
}

.checkbox-anonimizar input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.checkbox-anonimizar input[type="checkbox"]:checked ~ i {
    color: var(--sucesso);
}

/* Footer */
.footer {
    background: var(--azul-principal);
    color: var(--branco);
    text-align: center;
    padding: 20px;
    margin-top: auto;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

.footer p {
    margin: 0;
    font-size: 14px;
}

/* Alertas */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert i {
    font-size: 20px;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-warning i {
    color: #ffc107;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #28a745;
    color: #155724;
}

.alert-success i {
    color: #28a745;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

.alert-danger i {
    color: #dc3545;
}

/* Preview de Validação */
#validationPreview {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.validation-preview h3 {
    color: var(--text);
    margin: 25px 0 20px 0;
    font-size: 20px;
    font-weight: 600;
}

.comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.comparison-side {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
}

.comparison-side h4 {
    color: var(--text);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparison-side .info-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 10px;
    text-align: center;
}

/* Células compatíveis/incompatíveis */
.preview-table th.compatible,
.preview-table td.compatible {
    background: #d4edda !important;
    color: #155724;
}

.preview-table th.incompatible,
.preview-table td.incompatible {
    background: #f8d7da !important;
    color: #721c24;
}

/* Preview de exemplos nas colunas */
.column-sample {
    font-size: 12px;
    color: #6c757d;
    margin: 6px 0 10px 0;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 2px solid #17a2b8;
}

.column-sample code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #495057;
    margin: 0 2px;
}

/* Preview do nome da tabela */
.table-name-preview {
    display: block;
    margin-top: 8px;
    padding: 8px 12px;
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
    border-radius: 4px;
    color: #1565c0;
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.table-name-preview i {
    margin-right: 6px;
    color: #2196f3;
}

.table-name-preview strong {
    color: #0d47a1;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .card {
        padding: 20px;
    }
    
    .column-config-item {
        grid-template-columns: 1fr;
    }
    
    .radio-group {
        flex-direction: column;
    }
    
    .top-bar {
        padding: 10px 20px;
        height: auto;
    }
    
    .logo-header {
        height: 40px;
    }
    
    /* Comparação empilhada em mobile */
    .comparison-container {
        grid-template-columns: 1fr;
    }
}

/* Estilos para Login */
body:has(#loginSection:not([style*="display: none"])) {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

body:has(#loginSection:not([style*="display: none"])) .container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
}

#loginSection {
    max-width: 500px;
    margin: auto;
}

#loginSection h1 {
    font-size: 24px;
    margin-bottom: 10px;
}

#loginAlert {
    margin-bottom: 15px;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    color: var(--branco);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 14px;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}
