/* Import global HTV24-style theme */
@import url('../styles.css');

/* Mathe-specific accent color override */
:root {
    --accent-primary: #8b5cf6;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* Preserve accent colors in light mode */
[data-theme="light"] {
    --accent-primary: #7c3aed;
    --accent-secondary: #6d28d9;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

/* Additional Mathe-specific styles */
.function-graph {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 1.5rem 0;
    text-align: center;
    border: 1px solid var(--border-color);
}

.function-graph img, .function-graph svg {
    max-width: 100%;
}

.derivative-steps {
    background: var(--bg-card);
    border-left: 4px solid var(--accent-primary);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.derivative-steps .step {
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.derivative-steps .step:last-child {
    border-bottom: none;
}

.derivative-steps .step-number {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 0.5rem;
}

.rule-box {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(124, 58, 237, 0.05) 100%);
    border: 1px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.rule-box h4 {
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.coordinate-system {
    position: relative;
    background: var(--bg-secondary);
    padding: 20px;
    margin: 1.5rem 0;
    border-radius: var(--border-radius);
}

/* Math formula highlighting */
.important-formula {
    background: var(--accent-gradient);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-sm);
    display: inline-block;
    font-size: 1.1rem;
}

/* Example calculation box */
.example-calc {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.example-calc::before {
    content: '📝 Beispiel';
    display: block;
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

/* =====================================================
   KURVENDISKUSSION - New Components
   ===================================================== */

/* Step List for Schema */
.step-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

.step-item {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.step-item:hover {
    border-color: var(--accent-primary);
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.step-content h4 {
    color: var(--accent-primary);
    margin: 0 0 0.5rem 0;
    font-size: 1.05rem;
}

.step-content p, .step-content ul {
    margin: 0.25rem 0;
    color: var(--text-secondary);
}

.step-content ul {
    padding-left: 1.25rem;
}

/* Formula Box */
.formula-box {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(124, 58, 237, 0.03) 100%);
    border: 2px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.formula-box h3 {
    color: var(--accent-primary);
    margin-top: 0;
    font-size: 1.1rem;
}

.formula-box .small-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Solution Steps */
.solution-steps {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
}

.solution-steps h3 {
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.solution-steps .step {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    border-left: 4px solid var(--accent-primary);
}

.solution-steps .step h4 {
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
}

.solution-steps .step p {
    margin: 0.5rem 0;
}

/* Result Box */
.result-box {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-sm);
    margin-top: 1rem;
    font-size: 1.05rem;
}

/* Info Box Variants */
.info-box {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-left: 4px solid var(--accent-primary);
}

.info-box h3 {
    color: var(--accent-primary);
    margin-top: 0;
}

.info-box.important {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.05) 100%);
    border-left-color: #ef4444;
}

.info-box.important h3 {
    color: #ef4444;
}

/* Hover Cards */
.hover-card {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    display: block;
}

.hover-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.2);
    border-color: var(--accent-primary);
}

.hover-card h3 {
    color: var(--accent-primary);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Small Button */
.btn-small {
    display: inline-block;
    background: var(--accent-gradient);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-small:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* Aufgaben Section */
.aufgaben-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
}

.aufgaben-section h3 {
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.aufgabe-item {
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

.aufgabe-item h4 {
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.aufgabe-item .aufgabe-text {
    background: rgba(139, 92, 246, 0.1);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}

/* Collapsible Solution */
details.loesung {
    margin-top: 1rem;
}

details.loesung summary {
    background: var(--accent-gradient);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

details.loesung summary::-webkit-details-marker {
    display: none;
}

details.loesung summary:hover {
    transform: scale(1.02);
}

details.loesung summary::before {
    content: '👁️';
}

details.loesung[open] summary::before {
    content: '✅';
}

details.loesung .loesung-content {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem;
    margin-top: 0.75rem;
}

/* Highlight important terms */
.term {
    color: var(--accent-primary);
    font-weight: 600;
}

.term-high {
    color: #ef4444;
    font-weight: 600;
}

.term-low {
    color: #10b981;
    font-weight: 600;
}

/* Visual Divider */
.divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    margin: 3rem 0;
    border: none;
}

/* Table Styling */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.styled-table th {
    background: var(--accent-gradient);
    color: white;
    padding: 1rem;
    text-align: left;
}

.styled-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.styled-table tr:hover {
    background: var(--bg-secondary);
}

/* Search Bar Styles */
.search-wrapper {
    position: relative;
    margin-right: 1rem;
    display: flex;
    align-items: center;
}

.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

#searchInput {
    padding: 0.5rem 2rem 0.5rem 2rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    width: 200px;
    transition: all 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
    width: 250px;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.9rem;
    opacity: 0.6;
    pointer-events: none;
}

.search-close {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    width: 300px;
}

.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-secondary);
}

.search-result-title {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.search-result-snippet {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.search-match {
    background-color: rgba(139, 92, 246, 0.2);
    color: var(--accent-primary);
    font-weight: 600;
    border-radius: 2px;
}

.search-loading, .search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Highlighted term on page */
.highlighted-term {
    background-color: #fef08a; /* Yellow highlight */
    color: #854d0e;
    padding: 0 2px;
    border-radius: 2px;
    animation: pulse-highlight 2s infinite;
}

@keyframes pulse-highlight {
    0% { background-color: #fef08a; }
    50% { background-color: #fde047; }
    100% { background-color: #fef08a; }
}

/* Responsive adjustments for search */
@media (max-width: 900px) {
    .search-wrapper {
        margin-right: 0.5rem;
    }
    
    #searchInput {
        width: 150px;
        font-size: 0.85rem;
        padding: 0.4rem 1.8rem;
    }
    
    #searchInput:focus {
        width: 180px;
    }
    
    .search-icon {
        font-size: 0.8rem;
        left: 8px;
    }
    
    .search-close {
        right: 8px;
        font-size: 1rem;
    }
}

@media (max-width: 700px) {
    .search-wrapper {
        position: absolute;
        right: 60px;
        left: auto;
        transform: none;
        margin: 0;
        z-index: 1002;
    }
    
    #searchInput {
        width: 110px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.5rem 1.8rem 0.5rem 2rem;
        height: 38px;
    }
    
    #searchInput:focus {
        width: 140px;
    }
    
    .search-results {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: 65px;
        width: auto;
        max-width: calc(100vw - 2rem);
        max-height: 60vh;
    }
    
    .search-result-item {
        padding: 1rem;
    }
    
    .search-result-title {
        font-size: 1rem;
    }
    
    .search-result-snippet {
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    .search-wrapper {
        left: auto;
        right: 50px;
        transform: none;
    }
    
    #searchInput {
        width: 120px;
    }
    
    #searchInput:focus {
        width: 150px;
    }
}
