/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-primary);
    line-height: 1.6;
    padding: 2rem 1rem;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Page Wrapper - white content card on gradient background */
.page-wrapper {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

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

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

/* Sections */
section {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

section h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Configuration Section */
.config-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

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

.form-group input[type="text"],
.form-group textarea,
.form-group select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.section-group {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-light);
}

.conditional-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-white);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
}

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

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.form-actions {
    margin-top: 2rem;
    text-align: center;
}

.form-actions .btn {
    min-width: 300px;
    font-size: 1.125rem;
    padding: 1rem 2rem;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

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

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

.loading p {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Results Section */
.results-section {
    margin-top: 3rem;
}

/* Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
}

.toggle-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.toggle-label.active {
    color: var(--primary-color);
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--primary-color);
    transition: 0.4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Tab Content */
.tab-content-container {
    position: relative;
}

.tab-content {
    display: none;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

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

.result-header {
    background: var(--bg-white);
    padding: 1rem 1.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.result-header h3 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.25rem;
}

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

.output-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 2rem;
    color: var(--text-primary);
    background: var(--bg-white);
    max-height: 800px;
    overflow-y: auto;
}

.output-content h3.section-title {
    font-weight: 500;
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    text-align: left;
}

.output-content h4.subsection-title {
    font-weight: 500;
    font-size: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-align: left;
}

.output-content .field-label {
    font-weight: 500;
    color: var(--text-primary);
}

.output-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

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

.output-content p {
    margin-bottom: 1rem;
    font-weight: normal;
}

.output-content::-webkit-scrollbar {
    width: 10px;
}

.output-content::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.output-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

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

/* Loading Warning */
.loading h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    border: none;
    padding: 0;
}

.loading-warning {
    color: #f59e0b;
    font-weight: 500;
    margin-top: 1rem !important;
}

/* Error State */
.error-message {
    background: #fef2f2;
    color: var(--error-color);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--error-color);
    margin-top: 1rem;
}

/* Success Message */
.success-message {
    background: #f0fdf4;
    color: var(--success-color);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--success-color);
    margin-top: 1rem;
}

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

    header h1 {
        font-size: 2rem;
    }

    section {
        padding: 1.5rem;
    }

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

    .form-actions .btn {
        width: 100%;
    }

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

    .result-actions {
        width: 100%;
    }

    .result-actions .btn {
        flex: 1;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .config-section,
    .form-section,
    .loading,
    .btn {
        display: none;
    }

    .results-section {
        display: block !important;
    }

    .results-grid {
        display: block;
    }

    .result-panel {
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }
}
