:root {
    --cdf-bg: #0f172a;
    --cdf-surface: #1e293b;
    --cdf-surface-light: #334155;
    --cdf-primary: #f59e0b; /* Amber 500 */
    --cdf-primary-hover: #d97706;
    --cdf-secondary: #0ea5e9; /* Sky 500 */
    --cdf-text: #f8fafc;
    --cdf-text-dim: #94a3b8;
    --cdf-accent: #10b981; /* Emerald 500 */
    --cdf-danger: #f43f5e; /* Rose 500 */
    --cdf-glass: rgba(30, 41, 59, 0.7);
    --cdf-border: rgba(255, 255, 255, 0.1);
    --cdf-radius: 12px;
    --cdf-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --cdf-acc-gold: #fbbf24;
}

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

body.cdf-body {
    background-color: var(--cdf-bg);
    color: var(--cdf-text);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.cdf-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Header */
.cdf-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: var(--cdf-radius);
    border: 1px solid var(--cdf-border);
}

.cdf-main-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cdf-intro {
    max-width: 800px;
    margin: 0 auto;
    color: var(--cdf-text-dim);
}

/* Cards */
.cdf-card {
    background: var(--cdf-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--cdf-border);
    border-radius: var(--cdf-radius);
    padding: 24px;
    box-shadow: var(--cdf-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cdf-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--cdf-primary);
    border-bottom: 1px solid var(--cdf-border);
    padding-bottom: 10px;
}

/* Inputs */
.cdf-selection-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.cdf-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cdf-input-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cdf-text-dim);
}

/* Selectores e Inputs con especificidad reforzada para WordPress */
#cdf-app-wrapper .cdf-select, 
#cdf-app-wrapper .cdf-input {
    background-color: #1e293b !important;
    background: #1e293b !important;
    border: 1px solid var(--cdf-border) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    color: #ffffff !important;
    font-size: 1rem !important;
    width: 100% !important;
    transition: border-color 0.2s ease !important;
    appearance: auto !important; /* Asegurar que se vea la flecha nativa si es necesario */
    -webkit-appearance: auto !important;
}

#cdf-app-wrapper .cdf-select option {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

/* Blindaje contra Autofill amarillo de Chrome */
#cdf-app-wrapper .cdf-input:-webkit-autofill,
#cdf-app-wrapper .cdf-input:-webkit-autofill:hover, 
#cdf-app-wrapper .cdf-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #ffffff !important;
    -webkit-box-shadow: 0 0 0px 1000px #1e293b inset !important;
    transition: background-color 5000s ease-in-out 0s !important;
}

#cdf-app-wrapper .cdf-select:focus, 
#cdf-app-wrapper .cdf-input:focus {
    outline: none !important;
    border-color: var(--cdf-primary) !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2) !important;
}

/* Workspace Grid */
.cdf-workspace {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
}

.cdf-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Canvas / Graph */
.cdf-canvas-container {
    width: 100%;
    height: 500px;
    background: #ffffff;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--cdf-border);
}

.cdf-tooltip {
    position: absolute;
    background: #0f172a;
    color: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 2000;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    border: 1px solid #334155;
    backdrop-filter: blur(8px);
    line-height: 1.6;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.cdf-magnet-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border: 2px solid #ffffff;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    z-index: 999;
}

#cdf-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.cdf-schema-view {
    min-height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1e293b;
    border-radius: 8px;
    padding: 15px;
    overflow: hidden;
}

.cdf-schema-svg {
    width: 100%;
    height: auto;
    max-width: 520px;
    max-height: 400px;
    display: block;
}

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

.cdf-btn-wizard {
    background: var(--cdf-primary);
    color: #000;
    width: 100%;
    margin-top: 20px;
}

.cdf-btn-wizard:hover {
    background: var(--cdf-primary-hover);
    transform: translateY(-2px);
}

/* Results */
.cdf-results-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cdf-res-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--cdf-radius);
    padding: 20px;
}

.cdf-res-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1rem;
    color: var(--cdf-primary);
    border-bottom: 1px solid var(--cdf-border);
    padding-bottom: 8px;
    font-family: 'Outfit', sans-serif;
}

.cdf-res-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.cdf-res-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cdf-res-item span {
    font-size: 0.7rem;
    color: var(--cdf-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cdf-res-item strong {
    font-size: 1.25rem;
    color: var(--cdf-text);
    font-family: 'Outfit', sans-serif;
}

/* Footer & Glossary Update */
.cdf-footer {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-top: 40px;
    border-top: 1px solid var(--cdf-border);
}

.cdf-glossary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    font-size: 0.9rem;
    color: var(--cdf-text-dim);
    text-align: left !important;
}

.cdf-help-card p, 
.cdf-help-card h4 {
    text-align: left !important;
}

.cdf-footer-note {
    text-align: left !important;
    margin-top: 20px;
}

.cdf-other-calculators {
    text-align: center;
}

.cdf-hub-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0 40px;
}

.cdf-hub-btn {
    width: 100%;
    max-width: 400px;
    padding: 16px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.cdf-hub-btn:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}

.cdf-hub-btn.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: white; }
.cdf-hub-btn.green { background: linear-gradient(135deg, #22c55e, #15803d); color: white; }
.cdf-hub-btn.orange { background: linear-gradient(135deg, #f97316, #c2410c); color: white; }
.cdf-hub-btn.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: white; }

.cdf-links-title {
    font-size: 1rem;
    color: var(--cdf-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.cdf-links-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.cdf-link-card {
    background: var(--cdf-surface);
    padding: 15px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--cdf-primary);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.cdf-link-card:hover {
    background: var(--cdf-surface-light);
    border-color: var(--cdf-primary);
}

@media (max-width: 768px) {
    .cdf-links-grid {
        grid-template-columns: 1fr;
    }
}

/* Tooltip */
.cdf-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--cdf-primary);
    padding: 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* Responsive */
@media (max-width: 968px) {
    .cdf-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .cdf-selection-section {
        grid-template-columns: 1fr;
    }
    .cdf-inputs-grid {
        grid-template-columns: 1fr;
    }
    .cdf-main-title {
        font-size: 1.75rem;
    }
    .cdf-glossary-content {
        grid-template-columns: 1fr;
    }
    .cdf-canvas-container {
        height: 350px;
    }
}

.cdf-balance-hint {
    grid-column: 1 / -1;
    font-size: 0.82rem;
    color: var(--cdf-text-dim);
    margin-top: 0.5rem;
    padding: 0.6rem;
    background: rgba(251, 191, 36, 0.08);
    border-radius: 6px;
    border-left: 3px solid var(--cdf-acc-gold);
    line-height: 1.4;
}
