/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #1e3a8a;
    --primary-light: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
}

/* Header */
.main-header {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-light));
    color: white;
    padding: 1rem 0; /* menor altura do header */
    /* sem text-align center para permitir alinhamento à esquerda */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Container do header em linha */
.header-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.company-logo {
    height: 108px;
    width: auto;
}

.header-divider {
    width: 2px;
    height: 90px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.header-text {
    text-align: center;
}

.main-header h1 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    letter-spacing: -0.025em;
}

.main-header p {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Container Principal */
.container {
    display: flex;
    gap: 1.5rem;
    max-width: 1400px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    flex: 1;
}

/* Painel de Controles */
.control-panel {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    width: 360px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    height: fit-content;
}

.control-panel h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
    color: var(--gray-700);
}

/* Formulário */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.required {
    color: var(--danger);
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* Container de Curvas Dinâmico */
.curves-container {
    min-height: 100px;
    padding: 0.75rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.curves-container.has-curves {
    background: white;
    border: 1px solid var(--gray-200);
}

.placeholder-text {
    color: var(--gray-500);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem;
}

/* Seletor de Curvas - Estilo Chips */
.curves-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.curve-chip {
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border: 2px solid var(--gray-300);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    user-select: none;
}

.curve-chip:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.curve-chip.selected {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.curve-chip.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Contador de Seleção */
.selection-counter {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: 0.25rem;
    font-size: 0.813rem;
    color: var(--gray-600);
}

.selection-counter.warning {
    background: #fef3c7;
    color: #92400e;
}

.selection-counter.max-reached {
    background: #dcfce7;
    color: var(--success);
}

/* Switch de Litologia */
.switch-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 17px;
    margin-right: 0.75rem;
}

.switch-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch::before {
    content: "";
    position: absolute;
    width: 48px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 24px;
    transition: 0.3s;
}

.switch::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: 0.3s;
}

.switch-label input:checked + .switch::before {
    background: var(--primary-light);
}

.switch-label input:checked + .switch::after {
    transform: translateX(24px);
}

.switch-text {
    font-size: 0.875rem;
    color: var(--gray-700);
}

/* Botões */
.btn-generate {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-blue));
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-action {
    padding: 0.5rem 1rem;
    background: white;
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-action:hover:not(:disabled) {
    background: var(--primary-blue);
    color: white;
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: underline;
}

.btn-copy {
    padding: 0.5rem;
    background: var(--primary-light);
    color: white;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--primary-blue);
}

/* Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status Panel */
.status-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 0.375rem;
    border-left: 3px solid var(--primary-light);
}

.status-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.813rem;
    margin-bottom: 0.375rem;
}

.status-label {
    color: var(--gray-500);
}

.status-value {
    color: var(--gray-700);
    font-weight: 500;
}

/* Link Panel */
.link-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0fdf4;
    border-radius: 0.375rem;
    border: 1px solid var(--success);
}

.link-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.link-container {
    display: flex;
    gap: 0.5rem;
}

.link-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.25rem;
    font-size: 0.813rem;
    background: white;
}

/* Área de Visualização */
.visualization-area {
    flex: 1;
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.viz-header h2 {
    font-size: 1.25rem;
    color: var(--gray-700);
}

.viz-controls {
    display: flex;
    gap: 0.5rem;
}

.image-container {
    min-height: 500px;
    background: var(--gray-50);
    border: none;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
}

.image-container img {
    max-width: 100%;
    height: auto;
    display: block;
}

.placeholder {
    text-align: center;
    color: var(--gray-500);
    padding: 2rem;
}

.placeholder p {
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Loading State */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    z-index: 10;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Error Container */
.error-container {
    margin-top: 1rem;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 400px;
    max-height: 300px;
    background: var(--gray-900);
    color: #10b981;
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 1000;
}

.debug-panel h3 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.debug-panel pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Footer */
.main-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--gray-500);
    z-index: 100;
}

/* Animação Shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s;
}

/* Utilidades */
.hidden {
    display: none !important;
}

/* Responsividade */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
    }
    
    .debug-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
    }
}

@media (max-width: 768px) {
    .header-container {
        gap: 1rem;
    }
    
    .company-logo {
        height: 38px;
    }
    
    .header-divider {
        height: 35px;
    }
    
    .main-header h1 {
        font-size: 1.375rem;
    }
    
    .main-header p {
        font-size: 0.75rem;
    }
}

@media (max-width: 640px) {
    .viz-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-action {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header-container {
        gap: 0.75rem;
    }
    
    .company-logo {
        height: 32px;
        padding: 4px 6px;
    }
    
    .header-divider {
        display: none; /* Remove divisor em telas muito pequenas */
    }
    
    .main-header h1 {
        font-size: 1.125rem;
    }
    
    .main-header p {
        display: none; /* Esconde subtítulo em mobile pequeno para economizar espaço */
    }
}