/* ratioTrends.css - Professional Financial SaaS Version */

/* ===== CONTAINER AND LAYOUT ===== */
.ratio-trends-container {
    padding: 1.5rem;
    background: #FFFFFF;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

/* ===== VIEW MODE SELECTOR ===== */
.ratio-view-selector {
    display: flex;
    gap: 0.25rem;
    background: #f3f4f6;
    padding: 0.375rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}

.view-mode-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.view-mode-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.view-mode-btn.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.view-mode-icon {
    font-size: 1rem;
}

/* ===== ENHANCED CONTROLS ===== */
.ratio-trends-controls {
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    border: 1px solid #e5e7eb;
    transition: box-shadow 0.2s ease;
}

.ratio-trends-controls:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group > label:first-child {
    font-weight: 500;
    font-size: 0.875rem;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.period-selector {
    display: flex;
    gap: 0.5rem;
    background: white;
    padding: 0.375rem;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.period-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
}

.period-btn:hover {
    background: #f9fafb;
}

.period-btn.active {
    background: #3b82f6;
    color: white;
}

/* ===== RATIO CATEGORY SELECTOR ===== */
.ratio-category-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.category-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.category-chip:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.category-chip.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.category-chip-icon {
    font-size: 1rem;
}

.category-chip-count {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* ===== RATIO HEALTH DASHBOARD ===== */
.ratio-health-dashboard {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.health-score-card {
    background: #3b82f6;
    color: white;
    padding: 1.5rem;
    border-radius: 6px;
    text-align: center;
}

.health-score-value {
    font-size: 3rem;
    font-weight: 400;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    margin: 0.625rem 0;
}

.health-score-label {
    font-size: 0.875rem;
    opacity: 0.95;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.health-score-trend {
    margin-top: 0.625rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.key-insights-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.25rem;
}

.insight-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.insight-pill {
    padding: 0.375rem 0.75rem;
    border-radius: 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.insight-pill.positive {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
}

.insight-pill.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.insight-pill.negative {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.quick-actions-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.25rem;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-top: 0.75rem;
}

.action-btn {
    padding: 0.625rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: #f3f4f6;
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== GRID VIEW (ENHANCED) ===== */
.ratio-trends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.ratio-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    border-left: 3px solid #3b82f6;
}

.ratio-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ratio-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.ratio-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.ratio-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    flex-shrink: 0;
}

.ratio-status-indicator.warning {
    background: #f59e0b;
}

.ratio-status-indicator.danger {
    background: #ef4444;
}

.ratio-card-stats {
    margin-bottom: 1rem;
}

.primary-value {
    font-size: 1.75rem;
    font-weight: 400;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    color: #1f2937;
    display: block;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.primary-value-label,
.value-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
    display: block;
}

.value-context {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
}

.change-value {
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.change-value.favorable {
    color: #059669;
}

.change-value.unfavorable {
    color: #dc2626;
}

.change-arrow {
    font-size: 1rem;
}

.latest-value {
    color: #6b7280;
    font-weight: 400;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.average-value {
    color: #6b7280;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.benchmark-value {
    color: #8b5cf6;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.ratio-card-chart-container {
    flex-grow: 1;
    height: 120px;
    margin-bottom: 0.625rem;
    position: relative;
}

.ratio-mini-insights {
    font-size: 0.75rem;
    color: #6b7280;
    border-top: 1px solid #f3f4f6;
    padding-top: 0.625rem;
    line-height: 1.5;
}

/* ===== DASHBOARD VIEW ===== */
.dashboard-view {
    display: grid;
    gap: 1.5rem;
}

.dashboard-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===== RADAR CHART CONTAINER ===== */
.radar-chart-container {
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== HEATMAP VIEW ===== */
.ratio-heatmap-container {
    overflow-x: auto;
    margin-top: 1.25rem;
}

.ratio-heatmap {
    min-width: 800px;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.ratio-heatmap th,
.ratio-heatmap td {
    display: table-cell;
    padding: 0.625rem;
    text-align: center;
    border: 1px solid #e5e7eb;
    position: relative;
}

.ratio-heatmap th {
    background: #f9fafb;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.ratio-heatmap .period-header {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: 100px;
}

.heatmap-cell {
    cursor: pointer;
    transition: box-shadow 0.2s ease;
    font-weight: 400;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.heatmap-cell:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
    border-radius: 4px;
}

/* ===== CORRELATION MATRIX ===== */
.correlation-matrix-container {
    margin-top: 1.25rem;
}

.correlation-matrix {
    width: 100%;
    border-collapse: collapse;
}

.correlation-matrix th,
.correlation-matrix td {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    border: 1px solid #e5e7eb;
}

.correlation-cell {
    position: relative;
    cursor: pointer;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.correlation-cell:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
}

/* ===== ANALYSIS VIEW ===== */
.analysis-tabs {
    display: flex;
    gap: 0.25rem;
    background: #f3f4f6;
    padding: 0.375rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}

.analysis-tab {
    flex: 1;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
}

.analysis-tab:hover {
    background: rgba(255, 255, 255, 0.5);
}

.analysis-tab.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== INSIGHTS PANEL ===== */
.ratio-insights-panel {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.ratio-insights-panel h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #d97706;
    margin: 0 0 1.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.ratio-insight-card {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    border-left: 3px solid #f59e0b;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ratio-insight-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.5rem 0;
}

.ratio-insight-card p {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.6;
    margin: 0 0 0.75rem 0;
}

.insight-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.insight-action-btn {
    padding: 0.375rem 0.75rem;
    background: rgba(3, 105, 161, 0.1);
    border: 1px solid rgba(3, 105, 161, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #0369a1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.insight-action-btn:hover {
    background: rgba(3, 105, 161, 0.15);
    border-color: #0369a1;
}

/* ===== LOADING STATES ===== */
.ratio-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #6b7280;
}

.ratio-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* ===== TOOLTIPS ===== */
.ratio-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    max-width: 280px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ratio-tooltip.show {
    opacity: 1;
}

/* ===== BUTTON STYLES ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-success {
    background: #10b981;
    color: white;
    border-color: #059669;
}

.btn-success:hover {
    background: #059669;
}

.btn-secondary {
    background: #6b7280;
    color: white;
    border-color: #6b7280;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-info {
    background: #06b6d4;
    color: white;
    border-color: #0891b2;
}

.btn-info:hover {
    background: #0891b2;
}

.module-export-btn,
.module-action-btn {
    white-space: nowrap;
}

.module-export-btn svg,
.module-action-btn svg {
    flex-shrink: 0;
}

/* ===== ERROR AND WARNING MESSAGES ===== */
.module-error,
.module-warning {
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.module-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.module-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.module-error ul,
.module-warning ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .ratio-health-dashboard {
        grid-template-columns: 1fr;
    }

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

    .ratio-trends-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .ratio-trends-container {
        padding: 1.25rem;
    }

    .ratio-trends-grid {
        grid-template-columns: 1fr;
    }

    .ratio-view-selector {
        flex-wrap: wrap;
    }

    .view-mode-btn {
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
    }

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

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .ratio-trends-container {
        padding: 1rem;
    }

    .ratio-trends-controls {
        padding: 1rem;
    }

    .ratio-card {
        padding: 1rem;
    }

    .primary-value {
        font-size: 1.5rem;
    }

    .health-score-value {
        font-size: 2.5rem;
    }

    .category-chip {
        flex: 1;
        justify-content: center;
        min-width: fit-content;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .ratio-trends-container {
        background: white;
        box-shadow: none;
        border: 1px solid #d1d5db;
    }

    .ratio-view-selector,
    .ratio-trends-controls,
    .section-actions,
    .action-buttons {
        display: none;
    }

    .ratio-trends-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .ratio-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #d1d5db;
    }

    .dashboard-section {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #d1d5db;
    }

    .ratio-insights-panel {
        page-break-inside: avoid;
        border: 1px solid #d1d5db;
    }

    .health-score-card {
        background: #3b82f6;
        color: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .ratio-status-indicator {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== ACCESSIBILITY ===== */
.ratio-card:focus-within,
.dashboard-section:focus-within,
.ratio-insight-card:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.btn:focus,
.view-mode-btn:focus,
.period-btn:focus,
.category-chip:focus,
.analysis-tab:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
