/* ============================================
   CRONOGRAMA UNIFIED STYLES
   Merges overview + personal timeline

   NOTE: Core tokens from core/variables.css
   Page-specific variables scoped to .cronograma-page
   ============================================ */

/* Page-scoped variables (not polluting global :root) */
.cronograma-page,
.cronograma-section {
    /* Teal aliases (moved from core/variables.css) */
    --teal-primary: var(--teal-mid);
    --teal-secondary: var(--teal-soft);
    --teal-light: #5a9590;
    --teal-ultra-light: #e8f3f2;

    /* Neutral scale (moved from core/variables.css) */
    --neutral-50: #F9FAFB;
    --neutral-100: #F3F4F6;
    --neutral-200: #E5E7EB;
    --neutral-300: #D1D5DB;
    --neutral-400: #9CA3AF;
    --neutral-500: #6B7280;
    --neutral-600: #4B5563;
    --neutral-700: #374151;
    --neutral-800: #1F2937;
    --neutral-900: #111827;

    /* Paper/card backgrounds */
    --paper-white: #fefefe;
    --paper-cream: #f9f8f6;
    --card-bg: #ffffff;
    --bg-light: #f8f9fa;

    /* Ink/text colors */
    --ink-black: #1a1a1a;
    --ink-gray: #4a4a4a;
    --text-dark: #1e1e1e;
    --text-muted: #6c757d;

    /* Dividers */
    --divider-light: #e0e0e0;
    --divider-strong: #c0c0c0;

    /* Status colors (page-specific names) */
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;

    /* Spacing units */
    --baseline: 8px;
    --gutter: 24px;
}

/* Dark mode overrides for neutral scale */
[data-theme="dark"] .cronograma-page,
[data-theme="dark"] .cronograma-section {
    --neutral-50: #111827;
    --neutral-100: #1F2937;
    --neutral-200: #374151;
    --neutral-300: #4B5563;
    --neutral-400: #6B7280;
    --neutral-500: #9CA3AF;
    --neutral-600: #D1D5DB;
    --neutral-700: #E5E7EB;
    --neutral-800: #F3F4F6;
    --neutral-900: #F9FAFB;
}

/* ==========  Section Layout ========== */
.cronograma-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: calc(var(--baseline) * 4) var(--gutter);
}

.cronograma-section > h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    color: var(--teal-deep);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: calc(var(--baseline) * 2);
    padding-bottom: calc(var(--baseline) * 3);
    border-bottom: 3px solid var(--teal-primary);
    position: relative;
}

.cronograma-section > h1::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 120px;
    height: 3px;
    background: var(--teal-deep);
}

/* ==========  3. Tab Navigation ========== */
.cronograma-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    border-bottom: 2px solid var(--divider-light);
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-gray);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--teal-primary);
}

.tab-btn.active {
    color: var(--teal-deep);
    border-bottom-color: var(--teal-primary);
}

.tab-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==========  4. Tab 1: Overview (from cronograma.html) ========== */

/* Timeline Container */
.timeline-container {
    background: var(--paper-white);
    border: 2px solid var(--divider-light);
    padding: calc(var(--baseline) * 6) calc(var(--baseline) * 4);
    margin-bottom: calc(var(--baseline) * 6);
}

/* Timeline - Horizontal Editorial Layout */
.timeline {
    display: flex;
    align-items: center;
    margin-bottom: calc(var(--baseline) * 6);
    overflow-x: auto;
    padding: calc(var(--baseline) * 2) 0;
}

.timeline-year {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.timeline-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--divider-strong);
    border: 3px solid var(--paper-white);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.timeline-year:hover .timeline-dot {
    background: var(--teal-light);
    transform: scale(1.3);
}

.timeline-dot.active {
    background: var(--teal-primary);
    transform: scale(1.5);
    box-shadow: 0 0 0 4px var(--teal-ultra-light);
}

.timeline-dot.highlight {
    background: var(--teal-deep);
    transform: scale(1.5);
    box-shadow: 0 0 0 4px var(--teal-ultra-light);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px var(--teal-ultra-light);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(74, 128, 124, 0.2);
    }
}

.timeline-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ink-gray);
    margin-top: var(--baseline);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-connector {
    flex: 1;
    height: 3px;
    background: var(--divider-light);
    position: relative;
    z-index: 1;
    min-width: 40px;
}

/* Timeline Details */
.timeline-details {
    background: var(--paper-cream);
    padding: calc(var(--baseline) * 4);
    border: 2px solid var(--divider-light);
    border-left: 4px solid var(--teal-primary);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-details.show {
    opacity: 1;
    max-height: 1000px;
}

.timeline-details h4 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--teal-deep);
    margin-bottom: calc(var(--baseline) * 3);
    padding-bottom: var(--baseline);
    border-bottom: 2px solid var(--divider-light);
}

.timeline-details ul {
    list-style: none;
    padding: 0;
    margin-bottom: calc(var(--baseline) * 3);
}

.timeline-details li {
    padding: calc(var(--baseline) * 1.5) 0;
    padding-left: calc(var(--baseline) * 3);
    border-bottom: 1px solid var(--divider-light);
    position: relative;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--ink-black);
}

.timeline-details li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--teal-primary);
    border-radius: 50%;
}

.timeline-details li:last-child {
    border-bottom: none;
}

/* Year CTAs */
.year-ctas {
    display: flex;
    gap: calc(var(--baseline) * 2);
    flex-wrap: wrap;
    margin-top: calc(var(--baseline) * 3);
}

.cta-btn {
    padding: calc(var(--baseline) * 1.5) calc(var(--baseline) * 3);
    border: 2px solid;
    background: none;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--baseline);
}

.cta-primary {
    background: var(--teal-primary);
    border-color: var(--teal-primary);
    color: white;
}

.cta-primary:hover {
    background: var(--teal-deep);
    border-color: var(--teal-deep);
}

.cta-secondary {
    background: transparent;
    border-color: var(--ink-black);
    color: var(--ink-black);
}

.cta-secondary:hover {
    background: var(--ink-black);
    color: var(--paper-white);
}

/* Action Panel */
.action-panel {
    background: var(--paper-white);
    padding: calc(var(--baseline) * 5);
    border: 2px solid var(--divider-light);
}

.action-panel h4 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--teal-deep);
    margin-bottom: calc(var(--baseline) * 4);
    padding-bottom: calc(var(--baseline) * 2);
    border-bottom: 2px solid var(--divider-light);
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: calc(var(--baseline) * 2);
}

.action-btn {
    padding: calc(var(--baseline) * 2.5) calc(var(--baseline) * 3);
    border: 2px solid;
    background: none;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: calc(var(--baseline) * 1.5);
    justify-content: center;
}

.action-primary {
    background: var(--teal-primary);
    border-color: var(--teal-primary);
    color: white;
}

.action-primary:hover {
    background: var(--teal-deep);
    border-color: var(--teal-deep);
}

.action-secondary {
    background: transparent;
    border-color: var(--ink-black);
    color: var(--ink-black);
}

.action-secondary:hover {
    background: var(--ink-black);
    color: var(--paper-white);
}

/* ==========  5. Tab 2: My Timeline (from timeline.css) ========== */

/* Info Banner */
.info-banner {
    background: linear-gradient(135deg, #e8f4f3 0%, #d4e9e7 100%);
    border-left: 4px solid var(--teal-primary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.info-banner h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--teal-deep);
    margin-bottom: 1rem;
}

.info-banner ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-banner li {
    padding: 0.5rem 0;
    color: var(--text-dark);
}

.info-banner li strong {
    color: var(--teal-deep);
}

/* Profile Form Card */
.profile-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    margin-bottom: 2rem;
}

.profile-card h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field.full-width {
    grid-column: span 2;
}

.form-field.checkbox-field {
    flex-direction: row;
    align-items: center;
}

.form-field.checkbox-field label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.form-field.checkbox-field input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-field label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-field input,
.form-field select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--teal-primary);
    box-shadow: 0 0 0 3px rgba(74, 128, 124, 0.1);
}

.form-field .hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* Button */
.generate-button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    background: var(--teal-primary);
    color: white;
}

.generate-button:hover {
    background: var(--teal-deep);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 128, 124, 0.3);
}

/* Loading & Error */
.loading-spinner,
.error-message {
    display: none;
    text-align: center;
    padding: 2rem;
}

.loading-spinner.visible,
.error-message.visible {
    display: block;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--teal-primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message p {
    color: var(--danger-color);
    font-weight: 600;
}

/* Results Section */
.results-section {
    display: none;
}

.results-section.visible {
    display: block;
}

.results-section h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
}

.results-section h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

/* Alerts */
.alerts-container {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border-left: 4px solid;
    background: white;
}

.alert.success {
    border-left-color: var(--success-color);
    background: #d4edda;
}

.alert.warning {
    border-left-color: var(--warning-color);
    background: #fff3cd;
}

.alert.info {
    border-left-color: var(--info-color);
    background: #d1ecf1;
}

.alert-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.alert-message {
    color: var(--text-dark);
}

/* Chart Container */
.chart-container {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.chart-container h3 {
    margin-bottom: 1.5rem;
}

/* Milestones */
.milestones-section {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.milestones-list {
    display: grid;
    gap: 1rem;
}

.milestone-item {
    padding: 1rem;
    border-left: 3px solid var(--teal-primary);
    background: var(--bg-light);
    border-radius: 6px;
}

.milestone-date {
    font-weight: 700;
    color: var(--teal-deep);
    margin-bottom: 0.25rem;
}

.milestone-event {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.milestone-impact {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.milestone-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

.milestone-badge.nfe {
    background: #e3f2fd;
    color: #1976d2;
}

.milestone-badge.tax_start {
    background: #d4edda;
    color: #28a745;
}

.milestone-badge.tax_end {
    background: #f8d7da;
    color: #dc3545;
}

.milestone-badge.rate_change {
    background: #fff3cd;
    color: #856404;
}

.milestone-badge.obligation {
    background: #d1ecf1;
    color: #0c5460;
}

/* Obligations */
.obligations-section {
    margin-bottom: 2rem;
}

.obligations-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.obligation-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.obligation-card h4 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.obligation-card.end h4 {
    color: var(--danger-color);
}

.obligation-card.start h4 {
    color: var(--success-color);
}

.obligation-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.obligation-item {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.obligation-name {
    font-weight: 600;
    color: var(--text-dark);
}

.obligation-date {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Phases Table */
.phases-table {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
}

.phases-table table {
    width: 100%;
    border-collapse: collapse;
}

.phases-table th {
    background: var(--teal-primary);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.phases-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.phase-year {
    font-weight: 700;
    color: var(--teal-deep);
    font-size: 1.1rem;
}

.phase-label {
    font-weight: 600;
    color: var(--text-dark);
}

.phase-percentage {
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

.phase-events {
    font-size: 0.9rem;
}

.phase-events ul {
    margin: 0;
    padding-left: 1.5rem;
}

.phase-events li {
    margin: 0.25rem 0;
}

/* ==========  6. Responsive Design ========== */
@media (max-width: 1024px) {
    .cronograma-section {
        padding: calc(var(--baseline) * 3) calc(var(--baseline) * 2);
    }

    .cronograma-section > h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .cronograma-section > h1 {
        font-size: 2rem;
    }

    .timeline-container {
        padding: calc(var(--baseline) * 4) calc(var(--baseline) * 2);
    }

    .timeline {
        justify-content: flex-start;
    }

    .timeline-details h4 {
        font-size: 1.5rem;
    }

    .year-ctas {
        flex-direction: column;
    }

    .cta-btn {
        width: 100%;
        justify-content: center;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    /* Tab 2 responsive */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-field.full-width {
        grid-column: span 1;
    }

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

    .phases-table {
        overflow-x: scroll;
    }
}

@media (max-width: 480px) {
    .cronograma-section > h1 {
        font-size: 1.75rem;
    }

    .timeline-label {
        font-size: 0.6875rem;
    }

    .timeline-details h4 {
        font-size: 1.25rem;
    }

    .action-panel h4 {
        font-size: 1.5rem;
    }
}

/* ==========  7. Dark Theme ========== */
html[data-theme="dark"] .cronograma-section {
    color: #e8e8e8;
}

html[data-theme="dark"] .cronograma-section > h1 {
    color: #5fb9b4;
}

html[data-theme="dark"] .tab-btn {
    color: #a0a0a0;
}

html[data-theme="dark"] .tab-btn.active {
    color: #5fb9b4;
}

html[data-theme="dark"] .timeline-container,
html[data-theme="dark"] .action-panel,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .chart-container,
html[data-theme="dark"] .milestones-section,
html[data-theme="dark"] .obligation-card,
html[data-theme="dark"] .phases-table {
    background: #252525;
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .timeline-details {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .timeline-details h4,
html[data-theme="dark"] .action-panel h4,
html[data-theme="dark"] .profile-card h2 {
    color: #5fb9b4;
}

html[data-theme="dark"] .timeline-details li,
html[data-theme="dark"] .form-field label {
    color: #e8e8e8;
}

html[data-theme="dark"] .form-field input,
html[data-theme="dark"] .form-field select {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e8e8e8;
}

html[data-theme="dark"] .milestone-item,
html[data-theme="dark"] .obligation-item {
    background: #1a1a1a;
}

html[data-theme="dark"] .alert {
    background: #252525;
}
