/*
 * Estilos para o Gerador de Propostas THR v6.0
 * Design Moderno com Auto-Save e Estados de Loading
 */

.thr-form-container {
    font-family: var(--idh-font-family, 'Inter', sans-serif);
    color: var(--idh-text-color, #d1d5db);
    max-width: 1200px;
    margin: 0 auto;
}

/* --- CARDS MODERNOS --- */
.thr-card {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.8), rgba(55, 65, 81, 0.4));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.thr-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--idh-primary-gradient, linear-gradient(90deg, #3b82f6, #6366f1));
}

.thr-card-title {
    color: #f9fafb;
    margin-top: 0;
    margin-bottom: 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 1px solid var(--idh-border-color, #374151);
    padding-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.thr-card-title::before {
    content: '📋';
    font-size: 1.2em;
}

/* --- SISTEMA DE GRID RESPONSIVO --- */
.thr-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem 2rem;
}

.thr-grid-fixed-2-cols,
.thr-grid-container-2-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 2rem;
}

.thr-grid-span-full {
    grid-column: 1 / -1;
}

.thr-section-divider {
    margin: 1.5rem 0;
    border-top: 1px solid var(--idh-border-color, #374151);
    opacity: 0.3;
}

/* --- FORMULÁRIO ESTILIZADO --- */
.thr-form-group {
    margin-bottom: 0;
    position: relative;
}

.thr-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #d1d5db;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.thr-label::before {
    content: '→';
    color: var(--idh-primary-color, #3b82f6);
    font-weight: bold;
}

.thr-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.thr-input-adornment {
    position: absolute;
    left: 14px;
    font-size: 16px;
    color: #6b7280;
    pointer-events: none;
    z-index: 2;
}

.thr-input,
.thr-textarea {
    width: 100%;
    border: 1px solid #374151;
    border-radius: 10px;
    font-size: 16px;
    background: rgba(31, 41, 55, 0.6);
    color: #f9fafb;
    transition: all 0.3s ease;
    box-sizing: border-box;
    padding: 14px 16px;
    font-family: inherit;
}

.thr-input:focus,
.thr-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(17, 24, 39, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.thr-input::placeholder,
.thr-textarea::placeholder {
    color: #6b7280;
    opacity: 0.7;
}

.thr-input[readonly],
.thr-textarea[readonly] {
    background: rgba(17, 24, 39, 0.4);
    color: var(--idh-primary-color, #60a5fa);
    font-size: 1.3rem;
    font-weight: 600;
    border-color: rgba(59, 130, 246, 0.3);
    cursor: not-allowed;
}

.thr-conditional-input {
    margin-top: 1rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- BOTÕES DE GRUPO MELHORADOS --- */
.thr-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.thr-radio-group button {
    border: 1px solid var(--idh-border-color, #374151);
    background: rgba(31, 41, 55, 0.6);
    color: var(--idh-text-color, #d1d5db);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.thr-radio-group button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.thr-radio-group button:hover::before {
    left: 100%;
}

.thr-radio-group button:not(.active):hover {
    border-color: var(--idh-primary-color, #60a5fa);
    color: var(--idh-primary-color, #60a5fa);
    transform: translateY(-1px);
}

.thr-radio-group button.active {
    background: var(--idh-primary-gradient, linear-gradient(90deg, #3b82f6, #6366f1));
    color: #fff;
    font-weight: 600;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

/* --- AÇÕES PRINCIPAIS --- */
.thr-actions-container {
    text-align: center;
    margin-top: 2rem;
    position: relative;
}

.thr-button-group {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.thr-button {
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    min-width: 140px;
}

.thr-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.thr-button:hover::before {
    left: 100%;
}

.thr-button-primary {
    color: #fff;
    background: var(--idh-primary-gradient, linear-gradient(90deg, #3b82f6, #6366f1));
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.thr-button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.thr-button-secondary {
    color: var(--idh-text-color, #d1d5db);
    background: rgba(55, 65, 81, 0.8);
    border: 1px solid #4b5563;
    transition: all 0.3s ease;
}

.thr-button-secondary:hover {
    background: rgba(75, 85, 99, 0.8);
    transform: translateY(-1px);
}

.thr-button-secondary.copied {
    background: var(--idh-success-color, #10b981) !important;
    color: #fff !important;
    border-color: var(--idh-success-color, #10b981) !important;
}

.thr-button-whatsapp {
    background: linear-gradient(135deg, #25D366, #1DAA53);
    color: #fff;
    border: none;
}

.thr-button-whatsapp:hover {
    background: linear-gradient(135deg, #1DAA53, #25D366);
    transform: translateY(-1px);
}

/* --- AUTO-SAVE STATUS --- */
.thr-auto-save-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(10px);
}

.thr-auto-save-status.thr-success {
    background: rgba(16, 185, 129, 0.9);
    color: white;
    border-left: 4px solid #047857;
}

.thr-auto-save-status.thr-error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border-left: 4px solid #b91c1c;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- STATES DE LOADING --- */
.thr-loading {
    position: relative;
    pointer-events: none;
}

.thr-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top: 2px solid var(--idh-primary-color, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: -10px;
    margin-left: -10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- RESPONSIVIDADE --- */
@media (max-width: 1024px) {
    .thr-grid-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem 1.5rem;
    }
}

@media (max-width: 768px) {
    .thr-card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .thr-grid-fixed-2-cols,
    .thr-grid-container-2-cols {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .thr-button-group {
        flex-direction: column;
        align-items: center;
    }
    
    .thr-button {
        width: 100%;
        max-width: 300px;
    }
    
    .thr-radio-group {
        justify-content: center;
    }
    
    .thr-radio-group button {
        flex: 1;
        min-width: 120px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .thr-form-container {
        padding: 0 10px;
    }
    
    .thr-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .thr-input,
    .thr-textarea {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    .thr-button {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* --- ANIMAÇÕES ESPECIAIS --- */
.thr-card {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.thr-form-group {
    animation: slideInLeft 0.5s ease-out;
}

.thr-form-group:nth-child(odd) {
    animation-delay: 0.1s;
}

.thr-form-group:nth-child(even) {
    animation-delay: 0.2s;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* === MELHORIAS PARA A SEÇÃO DE VALORES === */

/* Campos monetários com indicação de preenchimento automático */
.thr-currency-input {
    position: relative;
    display: flex;
    align-items: center;
}

.thr-currency-input .thr-input-adornment {
    position: absolute;
    left: 14px;
    z-index: 2;
    font-weight: 600;
    color: #6b7280;
}

.thr-currency-input .thr-input {
    padding-left: 40px !important;
}

/* Campos de preenchimento automático */
.thr-auto-fill-field {
    background: rgba(59, 130, 246, 0.1) !important;
    border-left: 3px solid #3b82f6 !important;
    position: relative;
}

.thr-auto-fill-field::after {
    content: '(Automático)';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #3b82f6;
    font-style: italic;
    background: rgba(59, 130, 246, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Layout específico para a seção de valores */
.thr-values-grid-desktop {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.thr-values-left-column,
.thr-values-right-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.thr-values-section-desktop {
    background: rgba(31, 41, 55, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Grupo de campos condicionais lado a lado */
.thr-conditional-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Campos calculados em destaque */
.thr-calculated-values {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.thr-calculated-values .thr-form-group {
    margin-bottom: 0;
}

.thr-values-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.5), transparent);
    margin: 1rem 0;
}

/* Grupos de opções melhorados */
.thr-option-group-compact {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.thr-option-group-compact button {
    flex: 1;
    min-width: 80px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Campos condicionais com transição suave */
.thr-conditional-fields {
    margin-top: 1rem;
    animation: slideDown 0.3s ease-out;
    border-left: 2px solid #3b82f6;
    padding-left: 1rem;
}

/* Placeholders específicos para campos monetários */
.thr-input[placeholder="0,00"] {
    font-weight: 600;
    color: #f9fafb;
}

/* Estados dos campos calculados */
.thr-calculated-field {
    background: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
    color: #10b981 !important;
    font-weight: 700;
}

.thr-calculated-field::placeholder {
    color: #10b981 !important;
    opacity: 0.7;
}

/* === CORREÇÕES DE LEGIBILIDADE === */

/* Garante que campos preenchidos sejam legíveis */
.thr-input.has-value,
.thr-input:not([readonly]):not(:placeholder-shown) {
    color: #f9fafb !important;
    font-weight: 600;
}

/* Campos de entrada normais (não calculados) */
.thr-input:not(.thr-calculated-field) {
    color: #f9fafb;
    background: rgba(31, 41, 55, 0.8);
}

/* Placeholders visíveis */
.thr-input::placeholder {
    color: #6b7280 !important;
    opacity: 0.8;
}

/* Garante contraste para todos os estados */
.thr-input:not([readonly]) {
    color: #f9fafb !important;
}

/* Campos calculados mantêm a cor verde */
.thr-calculated-field {
    color: #10b981 !important;
    background: rgba(16, 185, 129, 0.1) !important;
}

.thr-input:focus {
    color: #f9fafb !important;
    background: rgba(17, 24, 39, 0.9) !important;
}

/* === MELHORIAS RESPONSIVAS === */
@media (min-width: 1024px) {
    .thr-values-section-desktop {
        min-height: 200px;
    }
    
    .thr-calculated-values {
        margin-top: 0;
        height: fit-content;
    }
}

@media (max-width: 1023px) {
    .thr-values-grid-desktop {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .thr-conditional-group {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .thr-values-grid-desktop {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .thr-option-group-compact {
        justify-content: center;
    }
    
    .thr-option-group-compact button {
        min-width: 100px;
    }
    
    .thr-auto-fill-field::after {
        position: static;
        transform: none;
        display: block;
        margin-top: 0.5rem;
        text-align: right;
    }
}

/* === ANIMAÇÕES ESPECÍFICAS === */
@keyframes highlightField {
    0% { background-color: rgba(59, 130, 246, 0.3); }
    100% { background-color: transparent; }
}

.thr-field-highlight {
    animation: highlightField 1s ease-in-out;
}

/* === CAMPOS DE PARCELAMENTO === */
.thr-parcelamento-fields {
    margin-top: 1rem;
    animation: slideDown 0.3s ease-out;
    border-left: 2px solid #f59e0b;
    padding-left: 1rem;
}

.thr-parcelamento-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}

.thr-parcela-info {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.thr-parcela-info strong {
    color: #f59e0b;
    display: block;
    margin-bottom: 0.25rem;
}

/* === CAMPO DE OBSERVAÇÕES === */
.thr-observacoes-section {
    margin-top: 2rem;
}

.thr-observacoes-field {
    min-height: 120px;
    resize: vertical;
}

.thr-observacoes-label::before {
    content: '📝' !important;
}

/* === RESPONSIVIDADE PARA PARCELAMENTO === */
@media (max-width: 768px) {
    .thr-parcelamento-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .thr-parcela-info {
        font-size: 0.85rem;
        padding: 0.75rem;
    }
}