/* ========================================
   Equation Solver Calculator Styles
   ======================================== */

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}


.glass-card > * {
    max-width: 100%;
}


/* Equation Type Selection */
.equation-type-selector {
    margin-bottom: 1.5rem;
}

.equation-type-selector label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.equation-type-selector select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #48bb78;
    border-radius: 12px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.1rem;
    background: #f0fff4;
    transition: all 0.3s ease;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2348bb78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 45px;
}

.equation-type-selector select:hover {
    border-color: #38a169;
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.1);
}

.equation-type-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

/* Input Section */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.input-group .form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group .form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group .form-input:invalid {
    border-color: #f56565;
}

/* Coefficient Inputs Grid */
.coefficients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.coefficient-input {
    display: flex;
    flex-direction: column;
}

.coefficient-input label {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.coefficient-input input {
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-align: center;
}

.coefficient-input input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* System of Equations Inputs */
.system-equations-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.equation-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

/* Three variable system (4 inputs: a, b, c, d) */
#system3Inputs .equation-row {
    grid-template-columns: repeat(4, 1fr);
}

/* Four variable system (5 inputs: a, b, c, d, e) */
#system4Inputs .equation-row {
    grid-template-columns: repeat(5, 1fr);
}

.equation-row-label {
    grid-column: 1 / -1;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.25rem;
}

.equation-row input {
    width: 100%;
    min-width: 0; /* Allow inputs to shrink below their content size */
}

/* Method Selection */
.method-selector {
    margin-bottom: 1.5rem;
}

/* Solve Button */
.btn-solve {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-solve:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.btn-solve:active {
    transform: translateY(0);
}

/* Results Section */
.result-container {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.result-item {
    margin-bottom: 1.5rem;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-value.large {
    font-size: 2.2rem;
}

.result-equation {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2d3748;
    font-family: 'Courier New', monospace;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* Discriminant Display */
.discriminant-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.discriminant-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

.discriminant-status {
    font-size: 0.9rem;
    color: #4a5568;
    font-style: italic;
}

.discriminant-status.positive {
    color: #48bb78;
}

.discriminant-status.zero {
    color: #ed8936;
}

.discriminant-status.negative {
    color: #f56565;
}

/* Roots Display */
.roots-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.root-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #e2e8f0;
}

.root-label {
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 0.5rem;
}

.root-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

/* No Solution Display */
.no-solution {
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.1) 0%, rgba(229, 62, 62, 0.1) 100%);
    border: 2px solid #fc8181;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    color: #c53030;
    font-weight: 600;
}

/* Steps Section */
.steps-container {
    margin-top: 1.5rem;
}

.step-item {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
}

.step-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateX(4px);
}

.step-number {
    display: inline-block;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 32px;
    font-weight: 700;
    margin-right: 0.75rem;
}

.step-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
    display: inline;
}

.step-content {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: #4a5568;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 6px;
}

/* Graph Container */
.graph-container {
    position: relative;
    width: 100%;
    height: 400px;
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

canvas {
    max-width: 100%;
    height: auto !important;
}

/* Action Buttons Grid */
.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Action Buttons */
.btn-custom,
.btn-custom-outline {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

.btn-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-custom-outline {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-custom-outline:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8edff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.btn-custom:active,
.btn-custom-outline:active {
    transform: translateY(0);
}

/* Sponsor Button */
.btn-sponsor {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

.btn-sponsor:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-sponsor:active {
    transform: translateY(0);
}

/* Tooltips */
.tooltip-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background: #cbd5e0;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 0.75rem;
    cursor: help;
    margin-left: 0.25rem;
}

/* SEO Section */
.seo-section {
    margin-top: 3rem;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.seo-section h2 {
    font-size: 1.8rem;
    color: #2d3748;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #667eea;
}

.seo-section h3 {
    font-size: 1.4rem;
    color: #4a5568;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.seo-section h4 {
    font-size: 1.2rem;
    color: #718096;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.seo-section p {
    line-height: 1.8;
    color: #4a5568;
    margin-bottom: 1rem;
}

.seo-section ul,
.seo-section ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.seo-section li {
    line-height: 1.8;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.seo-section strong {
    color: #667eea;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 992px) {
    .page-header h1 {
        font-size: 2rem;
    }

    .coefficients-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .graph-container {
        height: 350px;
    }
}

@media (max-width: 576px) {
    .glass-card {
        padding: 20px;
    }

    .main-container {
        padding: 1rem 0.5rem;
    }

    .page-header {
        padding: 1.5rem 1rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .page-header .subtitle {
        font-size: 1rem;
    }

    .coefficients-grid {
        grid-template-columns: 1fr;
    }

    .equation-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .equation-row input {
        font-size: 0.95rem;
        padding: 0.6rem;
    }

    .result-value {
        font-size: 1.5rem;
    }

    .result-value.large {
        font-size: 1.8rem;
    }

    .roots-display {
        grid-template-columns: 1fr;
    }

    .graph-container {
        height: 300px;
    }

    .action-buttons-grid {
        grid-template-columns: 1fr;
    }

    .step-content {
        font-size: 1rem;
    }
}

/* ========================================
   Enhancement: Fraction Support Styles
   ======================================== */

/* Input Mode Toggle */
.input-mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: #f7fafc;
    padding: 0.25rem;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: #718096;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
}

/* Fraction Input Container */
.fraction-input-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin: 0 0.25rem;
}

.fraction-numerator,
.fraction-denominator {
    width: 60px;
    padding: 0.25rem;
    text-align: center;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.fraction-numerator:focus,
.fraction-denominator:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.fraction-bar {
    width: 100%;
    height: 2px;
    background: #2d3748;
    margin: 2px 0;
}

/* Mixed Number Input */
.mixed-number-input {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.whole-number-input {
    width: 60px;
    padding: 0.5rem;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
}

/* ========================================
   Enhancement: Complex Roots Visualization
   ======================================== */

/* Complex Root Display */
.complex-root-display {
    background: linear-gradient(135deg, rgba(159, 122, 234, 0.1) 0%, rgba(237, 100, 166, 0.1) 100%);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.complex-root-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.complex-root-forms {
    display: flex;
    gap: 1.5rem;
}

.root-form {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-size: 0.75rem;
    color: #718096;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.form-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #9f7aea;
    font-family: 'Courier New', monospace;
}

/* Complex Plane (Argand Diagram) */
.complex-plane-container {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.complex-plane-canvas {
    width: 100%;
    height: 300px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

/* ========================================
   Enhancement: Parameter Animation
   ======================================== */

/* Parameter Controls */
.parameter-controls {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.parameter-slider {
    margin-bottom: 1.5rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.slider-name {
    font-weight: 600;
    color: #2d3748;
}

.slider-value {
    font-weight: 700;
    color: #667eea;
    font-family: 'Courier New', monospace;
}

.slider-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #e2e8f0 0%, #667eea 50%, #e2e8f0 100%);
    outline: none;
    transition: all 0.3s ease;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.slider-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: none;
    transition: all 0.3s ease;
}

.slider-input::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Animation Controls */
.animation-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.animation-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-play {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.btn-pause {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
}

.btn-reset-animation {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: white;
}

/* ========================================
   Enhancement: Equation Auto-Recognition
   ======================================== */

/* Text Input for Auto-Recognition */
.equation-text-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 60px;
}

.equation-text-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.equation-text-input.valid {
    border-color: #48bb78;
    background: #f0fff4;
}

.equation-text-input.invalid {
    border-color: #f56565;
    background: #fff5f5;
}

/* Recognition Status */
.recognition-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.status-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-icon.success {
    background: #48bb78;
    color: white;
}

.status-icon.error {
    background: #f56565;
    color: white;
}

.status-icon.loading {
    background: #ed8936;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

.status-text {
    color: #4a5568;
}

.status-text.success {
    color: #38a169;
}

.status-text.error {
    color: #e53e3e;
}

/* Parsed Equation Display */
.parsed-equation {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border: 2px solid #667eea;
    margin-top: 0.75rem;
}

.parsed-label {
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 0.5rem;
}

.parsed-content {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
    font-family: 'Courier New', monospace;
}

/* ========================================
   Enhancement: KaTeX Display
   ======================================== */

/* KaTeX Rendered Equations */
.katex-display {
    margin: 1rem 0;
    text-align: center;
    font-size: 1.2rem;
}

.katex-inline {
    margin: 0 0.25rem;
}

.step-equation {
    background: #f7fafc;
    padding: 0.75rem;
    border-radius: 6px;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.step-explanation {
    color: #718096;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* ========================================
   Enhancement: Detailed Steps Toggle
   ======================================== */

.steps-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.toggle-steps-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-steps-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.steps-detail-level {
    display: flex;
    gap: 0.5rem;
}

.detail-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    background: white;
    color: #718096;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.detail-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ========================================
   Enhancement: Mobile Responsive Updates
   ======================================== */

@media (max-width: 576px) {
    .fraction-input-container {
        margin: 0 0.125rem;
    }

    .fraction-numerator,
    .fraction-denominator,
    .whole-number-input {
        width: 50px;
        font-size: 0.85rem;
    }

    .complex-root-forms {
        flex-direction: column;
        gap: 0.75rem;
    }

    .parameter-controls {
        padding: 1rem;
    }

    .animation-controls {
        flex-direction: column;
    }

    .complex-plane-canvas {
        height: 250px;
    }
}
