/* Enhanced Styles for Math Help - Historical Context, Research Papers, Interactive Tools, and Ad Placement */

/* Historical Context Section */
.historical-context {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 60px 0;
    margin: 40px 0;
    border-radius: 12px;
}

.historical-context h2 {
    text-align: center;
    margin-bottom: 40px;
    color: var(--primary-color);
    font-size: 2.2em;
}

.history-timeline {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--secondary-color);
    transform: translateX(-50%);
}

.timeline-item {
    display: flex;
    align-items: center;
    margin: 40px 0;
    position: relative;
}

.timeline-item:nth-child(odd) {
    flex-direction: row-reverse;
}

.timeline-item:nth-child(odd) .timeline-content {
    text-align: right;
    padding-right: 40px;
}

.timeline-item:nth-child(even) .timeline-content {
    padding-left: 40px;
}

.timeline-year {
    background: var(--secondary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.timeline-content {
    flex: 1;
    max-width: 400px;
}

.timeline-content h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.4em;
}

.timeline-content p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.timeline-tag {
    background: var(--accent-color);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 500;
}

/* Research Papers Section */
.research-papers {
    background: white;
    padding: 60px 0;
    margin: 40px 0;
}

.research-papers h2 {
    text-align: center;
    margin-bottom: 40px;
    color: var(--primary-color);
    font-size: 2.2em;
}

.research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.research-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.research-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.research-badge {
    background: var(--secondary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 15px;
}

.research-card h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.3em;
    line-height: 1.3;
}

.research-authors {
    color: #666;
    font-style: italic;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.research-abstract {
    color: #555;
    line-height: 1.6;
    margin-bottom: 20px;
}

.research-links {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.research-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: color 0.3s ease;
}

.research-link:hover {
    color: var(--primary-color);
}

.research-relevance {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.relevance-tag {
    background: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
}

.research-cta {
    text-align: center;
}

/* Interactive Tools Section */
.interactive-tools {
    background: white;
    padding: 60px 0;
    margin: 40px 0;
}

.interactive-tools h2 {
    text-align: center;
    margin-bottom: 40px;
    color: var(--primary-color);
    font-size: 2.2em;
}

.calculator-tabs {
    max-width: 800px;
    margin: 0 auto 50px;
}

.tab-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab-btn {
    background: #e9ecef;
    color: var(--primary-color);
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active,
.tab-btn:hover {
    background: var(--secondary-color);
    color: white;
}

.calculator-widget {
    display: none;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.calculator-widget.active {
    display: block;
}

.calc-display {
    margin-bottom: 20px;
}

.calc-display input {
    width: 100%;
    padding: 15px;
    font-size: 1.5em;
    text-align: right;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.calc-buttons button {
    padding: 20px;
    font-size: 1.2em;
    border: none;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.calc-buttons button:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
}

.calc-buttons button.equals {
    background: var(--accent-color);
    color: white;
    grid-row: span 2;
}

.calc-buttons button.zero {
    grid-column: span 2;
}

.sci-calc-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.sci-calc-buttons button {
    padding: 15px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    background: var(--secondary-color);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sci-calc-buttons button:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

/* Graphing Calculator */
.graphing-interface {
    text-align: center;
}

.function-input {
    margin-bottom: 20px;
}

.function-input input {
    width: 70%;
    padding: 12px;
    font-size: 1.1em;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    margin-right: 10px;
}

.function-input button {
    padding: 12px 24px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.function-input button:hover {
    background: var(--primary-color);
}

#graph-canvas {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    margin: 20px 0;
    background: white;
}

.graph-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.graph-controls button {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.graph-controls button:hover {
    background: var(--primary-color);
}

/* Equation Solver */
.equation-solver h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.equation-input {
    margin-bottom: 30px;
}

.equation-input input {
    width: 70%;
    padding: 12px;
    font-size: 1.1em;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    margin-right: 10px;
}

.equation-input button {
    padding: 12px 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.equation-input button:hover {
    background: var(--primary-color);
}

.solution-display {
    text-align: left;
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.solution-step {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.solution-step h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.equation-display {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--accent-color);
    margin: 10px 0;
}

.solution-answer {
    background: var(--success-color);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

/* Specialized Tools */
.specialized-tools {
    margin-top: 50px;
}

.specialized-tools h3 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
    font-size: 1.8em;
}

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

.tool-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.tool-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.tool-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.3em;
}

.tool-card p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.tool-interface {
    text-align: left;
}

.tool-interface input,
.tool-interface select,
.tool-interface textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1em;
}

.tool-interface button {
    width: 100%;
    padding: 12px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.tool-interface button:hover {
    background: var(--primary-color);
}

/* Matrix Calculator */
.matrix-display {
    margin: 15px 0;
}

.matrix-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}

.matrix-cell {
    width: 60px !important;
    height: 40px;
    text-align: center;
    font-size: 1em;
    border: 2px solid #dee2e6;
    border-radius: 4px;
}

.matrix-size {
    margin-bottom: 15px;
}

.matrix-size label {
    margin-right: 10px;
    font-weight: 500;
}

/* Ad Placement Enhancements */
.ad-container {
    margin: 30px 0;
    text-align: center;
    position: relative;
}

.ad-label {
    font-size: 0.8em;
    color: #6c757d;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ad-container.sticky {
    position: sticky;
    top: 20px;
}

.ad-native {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 40px 0;
}

.ad-sidebar-native {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

.ad-after-tools {
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    padding: 30px 0;
    margin: 50px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .history-timeline::before {
        left: 20px;
    }
    
    .timeline-item {
        flex-direction: column;
        text-align: center;
    }
    
    .timeline-item:nth-child(odd) {
        flex-direction: column;
    }
    
    .timeline-item:nth-child(odd) .timeline-content,
    .timeline-item:nth-child(even) .timeline-content {
        text-align: center;
        padding: 20px;
    }
    
    .research-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .tab-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .calc-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .sci-calc-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .function-input input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .equation-input input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .graph-controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .graph-controls button {
        width: 100%;
    }
    
    .matrix-row {
        justify-content: center;
    }
    
    .matrix-cell {
        width: 50px !important;
        height: 35px;
    }
}

@media (max-width: 480px) {
    .historical-context,
    .research-papers,
    .interactive-tools {
        padding: 30px 0;
    }
    
    .historical-context h2,
    .research-papers h2,
    .interactive-tools h2 {
        font-size: 1.8em;
    }
    
    .timeline-content h3 {
        font-size: 1.2em;
    }
    
    .research-card {
        padding: 20px;
    }
    
    .calculator-widget {
        padding: 20px;
    }
    
    .calc-buttons button {
        padding: 15px;
        font-size: 1em;
    }
    
    .tool-card {
        padding: 20px;
    }
    
    #graph-canvas {
        width: 100%;
        height: 200px;
    }
}