/* ═══════════════════════════════════════════════════════════════
   Generador de Contratos EPC BESS — Estilos Premium Dark Mode
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset & Variables ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colores */
    --bg-deepest:    #060611;
    --bg-dark:       #0c0c1d;
    --bg-card:       rgba(15, 15, 35, 0.7);
    --bg-card-hover: rgba(20, 20, 45, 0.8);
    --bg-input:      rgba(255, 255, 255, 0.04);
    --bg-input-focus:rgba(255, 255, 255, 0.07);

    --accent:        #00b4d8;
    --accent-light:  #48cae4;
    --accent-dark:   #0077b6;
    --accent-glow:   rgba(0, 180, 216, 0.15);
    --accent-glow-strong: rgba(0, 180, 216, 0.3);

    --text-primary:  #e2e8f0;
    --text-secondary:#94a3b8;
    --text-muted:    #64748b;
    --text-placeholder: #475569;

    --border:        rgba(255, 255, 255, 0.08);
    --border-focus:  rgba(0, 180, 216, 0.5);

    --success:       #10b981;
    --success-bg:    rgba(16, 185, 129, 0.1);
    --error:         #ef4444;
    --error-bg:      rgba(239, 68, 68, 0.1);
    --warning:       #f59e0b;

    /* Espaciado */
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-xl:  20px;

    /* Transiciones */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Base ─── */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-deepest);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ─── Partículas decorativas de fondo ─── */
.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.p1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 180, 216, 0.15), transparent);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.p2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0, 119, 182, 0.12), transparent);
    bottom: 10%;
    left: -80px;
    animation-delay: -7s;
}

.p3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(72, 202, 228, 0.1), transparent);
    top: 40%;
    right: 5%;
    animation-delay: -14s;
}

.p4 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0, 180, 216, 0.08), transparent);
    top: 60%;
    left: 30%;
    animation-delay: -3s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(30px, -40px) scale(1.05); }
    50%      { transform: translate(-20px, 20px) scale(0.95); }
    75%      { transform: translate(15px, 30px) scale(1.02); }
}

/* ─── App Container ─── */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ─── Header ─── */
.app-header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInDown 0.6s ease-out;
}

.header-icon {
    margin-bottom: 16px;
    display: inline-block;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(0, 180, 216, 0.3)); }
    50%      { filter: drop-shadow(0 0 20px rgba(0, 180, 216, 0.6)); }
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.header-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ─── Form Sections (Glass Cards) ─── */
.form-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 28px 24px;
    margin-bottom: 20px;
    transition: var(--transition);
    animation: fadeInUp 0.5s ease-out backwards;
}

.form-section:nth-child(1) { animation-delay: 0.05s; }
.form-section:nth-child(2) { animation-delay: 0.10s; }
.form-section:nth-child(3) { animation-delay: 0.15s; }
.form-section:nth-child(4) { animation-delay: 0.20s; }
.form-section:nth-child(5) { animation-delay: 0.25s; }

.form-section:hover {
    border-color: rgba(0, 180, 216, 0.15);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 180, 216, 0.05);
}

/* ─── Section Headers ─── */
.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.section-icon {
    font-size: 1.3rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ─── Form Grid ─── */
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.form-grid.cols-1 {
    grid-template-columns: 1fr;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* ─── Form Groups ─── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.required {
    color: var(--accent);
    font-weight: 600;
}

/* ─── Inputs ─── */
input[type="text"],
input[type="number"],
input[type="date"],
.readonly-field {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

input::placeholder {
    color: var(--text-placeholder);
}

input:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px rgba(0, 180, 216, 0.05);
}

input:hover:not(:focus) {
    border-color: rgba(255, 255, 255, 0.15);
}

.readonly-field {
    opacity: 0.7;
    cursor: default;
    background: rgba(0, 180, 216, 0.04);
    border-color: rgba(0, 180, 216, 0.15);
    color: var(--accent-light);
    font-weight: 500;
}

/* ─── Checkbox ─── */
.checkbox-group {
    margin-bottom: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-secondary);
    user-select: none;
    transition: var(--transition);
}

.checkbox-label:hover {
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ─── Payment Milestones ─── */
.payment-milestones {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding: 20px 16px;
    background: rgba(0, 180, 216, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 180, 216, 0.08);
}

.milestone {
    text-align: center;
    flex: 1;
}

.milestone-input-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin: 6px 0 4px;
}

.milestone-input {
    width: 64px;
    padding: 6px 4px;
    background: rgba(0, 180, 216, 0.08);
    border: 1px solid rgba(0, 180, 216, 0.25);
    border-radius: 8px;
    color: var(--accent);
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    outline: none;
    transition: var(--transition);
    -moz-appearance: textfield;
}

.milestone-input::-webkit-inner-spin-button,
.milestone-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.milestone-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.milestone-unit {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    opacity: 0.7;
}

.milestone-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.milestone-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.milestone-total {
    min-width: 60px;
}

.milestone-sum {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--success);
    margin-top: 6px;
    transition: var(--transition);
}

.milestone-sum.invalid {
    color: var(--error);
}

.milestone-separator {
    color: var(--text-muted);
    font-size: 1.2rem;
    opacity: 0.4;
}

/* ─── Datasheet Picker (Tabs + Catalog Dropdown) ─── */
.datasheet-picker {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-input);
}

.picker-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.picker-tab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.picker-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.picker-tab.active {
    color: var(--accent);
    background: rgba(0, 180, 216, 0.06);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.picker-panel {
    padding: 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 160px;
    justify-content: center;
}

.picker-panel.hidden {
    display: none;
}

.picker-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.catalog-select {
    width: 100%;
    max-width: 380px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.catalog-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.catalog-select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

/* ─── Drop Zones ─── */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.drop-zone.dragover {
    border-color: var(--accent-light);
    background: var(--accent-glow-strong);
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(0, 180, 216, 0.15);
}

.drop-zone.has-file {
    border-style: solid;
    border-color: var(--success);
    background: var(--success-bg);
    cursor: default;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-icon {
    color: var(--text-muted);
    transition: var(--transition);
}

.drop-zone:hover .drop-icon {
    color: var(--accent);
    transform: translateY(-2px);
}

.drop-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.drop-formats {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 4px;
}

.drop-zone-success {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 500;
}

.drop-zone-success .file-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-file {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.remove-file:hover {
    background: var(--error);
    color: #fff;
}

/* ─── Generate Button ─── */
.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 32px;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out 0.3s backwards;
}

.generate-btn::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: 0.6s;
}

.generate-btn:hover::before {
    left: 100%;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 180, 216, 0.35);
}

.generate-btn:active {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-content,
.btn-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ─── Spinner ─── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Toast Notifications ─── */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    transition: var(--transition-slow);
    backdrop-filter: blur(12px);
    max-width: 500px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

/* ─── Footer ─── */
.app-footer {
    text-align: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    animation: fadeInUp 0.5s ease-out 0.35s backwards;
}

.app-footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ─── Responsive ─── */
@media (max-width: 700px) {
    .app-container {
        padding: 24px 16px 40px;
    }

    .form-grid.cols-2 {
        grid-template-columns: 1fr;
    }

    .upload-grid {
        grid-template-columns: 1fr;
    }

    .payment-milestones {
        flex-direction: column;
        gap: 16px;
    }

    .milestone-separator {
        transform: rotate(90deg);
    }

    .app-header h1 {
        font-size: 1.5rem;
    }

    .form-section {
        padding: 20px 18px;
    }
}
