/**
 * Formula Display Component Styles
 * Copyright (c) 2025 HJJB, LLC
 *
 * Styles for the formula display and code export components
 */

/* Main Container */
.formula-display-container {
    margin: 1.5rem 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Details/Summary Styling */
.formula-details {
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    transition: all 0.2s ease;
}

.formula-details[open] {
    border-color: #3b82f6;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.formula-summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: #1f2937;
    list-style: none;
    transition: background-color 0.2s ease;
}

.formula-summary::-webkit-details-marker {
    display: none;
}

.formula-summary:hover {
    background-color: #f9fafb;
}

.formula-summary-icon {
    font-size: 1.25rem;
}

.formula-summary-text {
    flex: 1;
    font-size: 1.1rem;
}

.formula-summary-toggle {
    transition: transform 0.2s ease;
    font-size: 0.875rem;
    color: #6b7280;
}

.formula-details[open] .formula-summary-toggle {
    transform: rotate(180deg);
}

/* Content Area */
.formula-content {
    padding: 1.5rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: linear-gradient(to bottom, #f9fafb, #ffffff);
}

/* Sections */
.formula-section {
    margin-bottom: 1.5rem;
}

.formula-section:last-child {
    margin-bottom: 0;
}

.formula-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.formula-section-content {
    padding-left: 0.5rem;
}

/* Formula Items */
.formula-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #ffffff;
    border-left: 3px solid #3b82f6;
    border-radius: 0.375rem;
}

.formula-description {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.formula-latex {
    font-size: 1.1rem;
    overflow-x: auto;
    padding: 0.5rem 0;
}

/* Variables */
.variable-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #f0f9ff;
    border-radius: 0.375rem;
    font-family: 'Courier New', Courier, monospace;
}

.variable-name {
    font-weight: 600;
    color: #1e40af;
}

.variable-equals {
    color: #6b7280;
}

.variable-value {
    font-weight: 600;
    color: #0f766e;
}

.variable-description {
    font-size: 0.875rem;
    color: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-style: italic;
}

/* Calculation Steps */
.step-item {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.step-number {
    display: inline-block;
    background: #3b82f6;
    color: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.step-description {
    font-size: 0.95rem;
    color: #374151;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.step-formula, .step-substituted {
    margin: 0.5rem 0;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 0.375rem;
    overflow-x: auto;
}

.step-result {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #ecfdf5;
    border-left: 3px solid #10b981;
    border-radius: 0.375rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.step-result-label {
    font-weight: 600;
    color: #065f46;
    font-size: 0.9rem;
}

.step-result-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    color: #047857;
    font-size: 1.05rem;
}

/* Results */
.result-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 2px solid #10b981;
    border-radius: 0.5rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.result-name {
    font-weight: 600;
    color: #065f46;
    font-size: 1rem;
}

.result-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    color: #047857;
    font-size: 1.25rem;
}

.result-interpretation {
    font-size: 0.9rem;
    color: #065f46;
    font-style: italic;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #86efac;
}

/* Export Button */
.export-code-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.export-code-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 8px -1px rgb(0 0 0 / 0.15);
    transform: translateY(-1px);
}

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

.export-code-icon {
    font-size: 1.25rem;
}

/* Export Modal */
.formula-export-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.formula-export-modal.active {
    opacity: 1;
}

.formula-export-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.formula-export-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    display: flex;
    flex-direction: column;
}

.formula-export-header {
    padding: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.formula-export-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.formula-export-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.formula-export-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.formula-export-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.formula-export-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.formula-export-tab {
    padding: 0.5rem 1rem;
    background: #f3f4f6;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.formula-export-tab:hover {
    background: #e5e7eb;
    color: #374151;
}

.formula-export-tab.active {
    background: #3b82f6;
    color: #ffffff;
}

.formula-export-code-container {
    background: #1f2937;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    max-height: 400px;
    overflow: auto;
}

.formula-export-code {
    color: #f3f4f6;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre;
}

.formula-export-actions {
    display: flex;
    gap: 0.75rem;
}

.formula-export-copy-btn,
.formula-export-download-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.formula-export-copy-btn {
    background: #10b981;
    color: #ffffff;
}

.formula-export-copy-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.formula-export-download-btn {
    background: #3b82f6;
    color: #ffffff;
}

.formula-export-download-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .formula-export-content {
        width: 95%;
        max-height: 95vh;
    }

    .formula-export-header {
        padding: 1rem;
    }

    .formula-export-body {
        padding: 1rem;
    }

    .formula-export-tabs {
        flex-wrap: wrap;
    }

    .formula-export-tab {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .variable-item {
        flex-wrap: wrap;
    }
}

/* Dark Theme Support */
.formula-display-container.dark {
    color-scheme: dark;
}

.formula-display-container.dark .formula-details {
    background: #1f2937;
    border-color: #374151;
}

.formula-display-container.dark .formula-summary {
    color: #f3f4f6;
}

.formula-display-container.dark .formula-content {
    background: linear-gradient(to bottom, #111827, #1f2937);
    border-top-color: #374151;
}

.formula-display-container.dark .formula-item {
    background: #111827;
}

.formula-display-container.dark .step-item {
    background: #111827;
    border-color: #374151;
}

/* Print Styles */
@media print {
    .formula-details {
        border: 1px solid #000;
    }

    .formula-details[open] {
        display: block;
    }

    .formula-summary {
        display: none;
    }

    .export-code-btn {
        display: none;
    }

    .formula-content {
        border: none;
        padding: 0;
    }
}
