/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* Info Card Collapsible */
.info-card-collapsible {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.125rem;
}

.info-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.info-icon {
    font-size: 1.5rem;
}

.info-title {
    flex: 1;
    text-align: left;
    font-weight: 600;
    font-size: 1.25rem;
}

.chevron {
    transition: transform 0.3s ease;
    font-size: 0.875rem;
    opacity: 0.8;
}

.info-toggle.active .chevron {
    transform: rotate(180deg);
}

.info-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.info-content.open {
    max-height: 2000px;
    padding: 2rem 1.5rem;
}

/* Markdown content styling */
.info-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.info-content h3:first-child {
    margin-top: 0;
}

.info-content p {
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.info-content ol {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.info-content ol > li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.info-content ol > li:last-child {
    margin-bottom: 0;
}

.info-content ul {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.info-content ul li {
    margin-bottom: 0.5rem;
}

.info-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.info-content p.tip {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border-left: 4px solid #f39c12;
    color: #856404;
    margin-top: 1.5rem;
}

.info-content p.tip strong {
    color: #856404;
}

.info-content .tip {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border-left: 4px solid #f39c12;
    color: #856404;
    margin-top: 1.5rem;
}

.info-content .tip strong {
    color: #856404;
}

/* Legacy class support */
.info-section {
    margin-bottom: 1.5rem;
}

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

.info-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.info-section p {
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.how-to-list {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.how-to-list li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.how-to-list li:last-child {
    margin-bottom: 0;
}

.how-to-list ul {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.how-to-list ul li {
    margin-bottom: 0.5rem;
}

.info-section.tip {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border-left: 4px solid #f39c12;
    color: #856404;
}

.info-section.tip strong {
    color: #856404;
}

/* Card */
.card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input[type="number"],
.form-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Wing Selector */
.wing-selector {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
    background: var(--background);
}

.wing-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    border: 2px solid transparent;
}

.wing-item:hover {
    background-color: rgba(37, 99, 235, 0.05);
}

.wing-item.selected {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
}

.wing-info {
    flex: 1;
}

.wing-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.wing-specs {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Flow Type Checkboxes */
.flow-type-checkboxes {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: var(--background);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.flow-checkbox {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    cursor: pointer;
}

.flow-checkbox:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.flow-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    accent-color: var(--primary-color);
}

.flow-checkbox label {
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

/* Laminar Flow - Blue theme */
.laminar-flow {
    border-left: 3px solid #3b82f6;
}

.laminar-flow label {
    color: #1e40af;
}

.laminar-flow input[type="checkbox"] {
    accent-color: #3b82f6;
}

/* Turbulent Flow - Orange theme */
.turbulent-flow {
    border-left: 3px solid #f97316;
}

.turbulent-flow label {
    color: #c2410c;
}

.turbulent-flow input[type="checkbox"] {
    accent-color: #f97316;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem;
}

/* Checkbox Group */
.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

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

/* Button */
.btn {
    display: inline-block;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-lg);
}

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

.btn-loader {
    display: inline-block;
}

/* Results Section */
#resultsSection {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    margin-bottom: 2rem;
}

.result-item:last-child {
    margin-bottom: 0;
}

/* Summary Grid */
.summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--background);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.summary-card h4 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-card .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-card .unit {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

/* Image Container */
.image-container {
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: white;
}

.image-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* Chart Container for Plotly */
.chart-container {
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: white;
    min-height: 400px;
    padding: 0.5rem;
    height: auto;  /* Ensure height auto-adjusts to content */
}

/* Performance plot container needs explicit height handling */
#performancePlot {
    min-height: 500px;  /* Ensure minimum height after fullscreen exit */
}

/* Fullscreen styles for chart containers */
.chart-container:fullscreen {
    background: white;
    padding: 1rem;
    width: 100vw;
    height: 100vh;
}

.chart-container:-webkit-full-screen {
    background: white;
    padding: 1rem;
    width: 100vw;
    height: 100vh;
}

.chart-container:-moz-full-screen {
    background: white;
    padding: 1rem;
    width: 100vw;
    height: 100vh;
}

/* Ensure Plotly div fills the fullscreen container */
.chart-container:fullscreen > div,
.chart-container:-webkit-full-screen > div,
.chart-container:-moz-full-screen > div {
    width: 100% !important;
    height: 100% !important;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* Summary Info Cards */
.summary-info-cards {
    flex: 1;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.info-card {
    flex: 1;
    min-width: 200px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.info-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.info-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f77b4;
}

/* Summary Table - Plotly Style */
.summary-table {
    flex: 2;
    max-width: 1200px;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.summary-table thead tr {
    background: #1f77b4;
    color: white;
}

.summary-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s ease;
}

.summary-table tbody tr:last-child {
    border-bottom: none;
}

.summary-table tbody tr:hover {
    background-color: #f9fafb;
}

.summary-table td {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    color: #374151;
}

.summary-table td.wing-name {
    font-weight: 600;
    color: #1f77b4;
}

/* Mobile responsiveness for summary table */
@media (max-width: 768px) {
    .summary-info-cards {
        flex-direction: column;
    }
    
    .info-card {
        min-width: 100%;
    }
    
    .summary-table {
        width: 100%;  /* Full width on mobile */
        font-size: 0.875rem;
    }
    
    .summary-table th,
    .summary-table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Stack flow type checkboxes vertically on mobile */
    .flow-type-checkboxes {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .flow-checkbox {
        width: 100%;
    }
}

/* Error Card */
.error-card {
    background: #fef2f2;
    border-color: var(--error-color);
    animation: fadeIn 0.3s ease-in;
}

.error-card h2 {
    color: var(--error-color);
}

.error-card p {
    color: #991b1b;
    line-height: 1.6;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }

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

    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .info-toggle {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .info-title {
        font-size: 1.125rem;
    }
    
    .info-content.open {
        padding: 1.5rem 1rem;
    }
    
    .info-content h3 {
        font-size: 1.125rem;
    }
    
    .info-content ol,
    .info-content ul {
        padding-left: 1.25rem;
    }
    
    .info-section h3 {
        font-size: 1.125rem;
    }
    
    .how-to-list {
        padding-left: 1.25rem;
    }
    
    .how-to-list ul {
        padding-left: 1.25rem;
    }
}

/* Scrollbar Styling */
.wing-selector::-webkit-scrollbar {
    width: 8px;
}

.wing-selector::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.wing-selector::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.wing-selector::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
