/* === PAGE ÉTUDE DE FONCTION - CSS === */

/* Styles pour les expressions mathématiques */
.math {
    font-family: times;
    padding: 0 .1em;
    font-size: 1.2em;
    font-style: normal;
}

.ct {
    text-align: center;
}

/* Container principal pour la page */
main .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Header de la page */
.page-header.cours-particuliers-header {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 120px 0 80px;
    position: relative;
    color: white;
    text-align: center;
}

.page-header.cours-particuliers-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.page-header .header-content {
    position: relative;
    z-index: 2;
}

.page-header .page-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

.page-header .page-subtitle {
    font-size: 1.5rem;
    font-weight: 400;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Section de saisie de fonction */
.function-input-section {
    background: #f8fafc;
    border-radius: 16px;
    box-shadow: 0 2px 12px #e0e7ef;
    padding: 24px 20px;
    margin: 30px auto;
    border: 1px solid #e2e8f0;
    max-width: 100%;
    width: 100%;
}

.function-input-section h2 {
    color: #1e293b;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.function-input-section p {
    color: #64748b;
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.6;
}

.input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    max-width: 600px;
    margin: 0 auto;
}

.input-group label {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
}

.input-group input {
    flex: 1;
    min-width: 300px;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#trace-btn {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

#trace-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Section du graphique */
.graph-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin: 30px auto;
    border: 1px solid #e2e8f0;
    max-width: 100%;
    width: 100%;
}

.graph-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e2e8f0;
}

.graph-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

#function-canvas {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.graph-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.control-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-btn:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
    transform: translateY(-1px);
}

.control-btn i {
    color: #64748b;
    font-size: 14px;
}

.coordinates-display {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    z-index: 10;
    pointer-events: none;
}

.legend-display {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    z-index: 15;
    pointer-events: none;
    display: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

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

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

/* Section d'analyse */
.analysis-section {
    margin: 30px 0;
}

.analysis-section h2 {
    color: #1e293b;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 20px;
    margin-top: 50px;
    text-align: center;
}

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.analysis-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    border: 1px solid #e2e8f0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 100px !important;
}

/* Espacement spécifique pour les rubriques d'analyse */
.analysis-section .analysis-card {
    margin-bottom: 100px !important;
}

.analysis-section .analysis-card:last-child {
    margin-bottom: 0 !important;
}

.analysis-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.analysis-card h3 {
    color: #1e293b;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-card h3 i {
    color: #3b82f6;
    font-size: 1.1rem;
}

.result-content {
    color: #374151;
    font-size: 1rem;
    line-height: 1.6;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.result-content.math {
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
}

.result-content.loading {
    color: #6b7280;
    font-style: italic;
}

.result-content.error {
    color: #dc2626;
    font-weight: 500;
}

/* Tableaux de variation et de signe */
.variation-table, .sign-table {
    overflow-x: auto;
}

/* Styles très spécifiques pour forcer l'affichage des bordures */
#variation-table table, #sign-table table {
    border: 2px solid #1e40af !important;
    border-collapse: collapse !important;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.15) !important;
}

#variation-table th, #variation-table td,
#sign-table th, #sign-table td {
    border: 1px solid #3b82f6 !important;
    padding: 12px !important;
    background: white !important;
}

#variation-table th, #sign-table th {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
    font-weight: bold !important;
    color: #1e40af !important;
    border-bottom: 2px solid #1e40af !important;
}

.variation-table table, .sign-table table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 8px !important;
    border: 2px solid #1e40af !important;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.15) !important;
}

.variation-table th, .variation-table td,
.sign-table th, .sign-table td {
    border: 1px solid #3b82f6 !important;
    padding: 12px 16px !important;
    text-align: center !important;
    font-size: 1rem !important;
    min-width: 60px !important;
    background: white !important;
}

.variation-table th, .sign-table th {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
    font-weight: 600 !important;
    color: #1e40af !important;
    border-bottom: 2px solid #1e40af !important;
    border-right: 1px solid #3b82f6 !important;
}

.variation-table td, .sign-table td {
    border-right: 1px solid #3b82f6 !important;
    border-bottom: 1px solid #3b82f6 !important;
}

.variation-table tr:last-child td, .sign-table tr:last-child td {
    border-bottom: 1px solid #3b82f6 !important;
}

.variation-table td:last-child, .sign-table td:last-child {
    border-right: 1px solid #3b82f6 !important;
}

.variation-table .arrow-up {
    color: #059669;
    font-weight: bold;
    font-size: 1.2rem;
}

.variation-table .arrow-down {
    color: #dc2626;
    font-weight: bold;
    font-size: 1.2rem;
}

.sign-table .positive {
    color: #059669;
    font-weight: bold;
    font-size: 1.2rem;
}

.sign-table .negative {
    color: #dc2626;
    font-weight: bold;
    font-size: 1.2rem;
}

.sign-table .zero {
    color: #3b82f6;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Styles pour les expressions mathématiques HTML */
.math {
    font-family: 'Times New Roman', serif;
    font-size: 1.1em;
    line-height: 1.4;
}

.math sup {
    font-size: 0.7em;
    vertical-align: super;
}

.math .fraction {
    display: inline-block;
    vertical-align: middle;
    text-align: center;
}

.math .fraction .numerator {
    display: block;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
    margin-bottom: 2px;
}

.math .fraction .denominator {
    display: block;
    padding-top: 2px;
}

/* Responsive design */
@media (max-width: 768px) {
    .page-header .page-title {
        font-size: 2.5rem;
    }
    
    .page-header .page-subtitle {
        font-size: 1.2rem;
    }
    
    .function-input-section {
        padding: 24px 16px;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .input-group input {
        min-width: auto;
        width: 100%;
    }
    
    .graph-container {
        padding: 16px;
    }
    
    #function-canvas {
        width: 100%;
        height: 400px;
    }
    
    .analysis-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        max-width: 100%;
    }
    
    .analysis-card {
        padding: 20px;
    }
    
    .graph-controls {
        top: 16px;
        right: 16px;
    }
    
    .coordinates-display {
        top: 16px;
        left: 16px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .legend-display {
        bottom: 16px;
        right: 16px;
        font-size: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .page-header .page-title {
        font-size: 2rem;
    }
    
    .function-input-section h2 {
        font-size: 1.5rem;
    }
    
    .analysis-section h2 {
        font-size: 1.5rem;
    }
    
    #function-canvas {
        height: 300px;
    }
    
    .analysis-card {
        padding: 16px;
    }
    
    .analysis-card h3 {
        font-size: 1.1rem;
    }
}

/* Styles pour le tableau de valeurs */
.values-table-container {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    margin: 10px 0;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    /* Améliorer le défilement */
    scrollbar-width: thin;
    scrollbar-color: #3b82f6 #e2e8f0;
}

/* Styles pour la scrollbar WebKit (Chrome, Safari, Edge) */
.values-table-container::-webkit-scrollbar {
    height: 8px;
}

.values-table-container::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 4px;
}

.values-table-container::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 4px;
}

.values-table-container::-webkit-scrollbar-thumb:hover {
    background: #1d4ed8;
}

.values-table {
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
    margin: 0;
    /* Limiter la largeur maximale */
    max-width: 800px;
}

.values-table th,
.values-table td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: center;
    white-space: nowrap;
    min-width: 50px;
    width: 50px;
    background: white;
    box-sizing: border-box;
}

.values-table .label-cell {
    background-color: #dbeafe !important;
    color: #1e40af !important;
    font-weight: 700 !important;
    border-right: 2px solid #3b82f6 !important;
    min-width: 60px !important;
    width: 60px !important;
    position: sticky;
    left: 0;
    z-index: 10;
}

.values-table tr:first-child td:not(.label-cell) {
    background-color: #f1f5f9;
    font-weight: 600;
    color: #1e293b;
    border-bottom: 2px solid #3b82f6;
}

.values-table tr:last-child td:not(.label-cell) {
    background-color: white;
    color: #374151;
    font-weight: 500;
}

/* Responsive pour le tableau de valeurs */
@media (max-width: 768px) {
    .values-table {
        font-size: 11px;
        max-width: 600px;
    }
    
    .values-table th,
    .values-table td {
        padding: 4px 6px;
        min-width: 45px;
        width: 45px;
    }
    
    .values-table .label-cell {
        min-width: 55px !important;
        width: 55px !important;
    }
}

@media (max-width: 480px) {
    .values-table {
        font-size: 10px;
        max-width: 500px;
    }
    
    .values-table th,
    .values-table td {
        padding: 3px 4px;
        min-width: 40px;
        width: 40px;
    }
    
    .values-table .label-cell {
        min-width: 50px !important;
        width: 50px !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.analysis-section {
    animation: fadeIn 0.6s ease-out;
}

.analysis-card {
    animation: fadeIn 0.6s ease-out;
}

.analysis-card:nth-child(1) { animation-delay: 0.1s; }
.analysis-card:nth-child(2) { animation-delay: 0.2s; }
.analysis-card:nth-child(3) { animation-delay: 0.3s; }
.analysis-card:nth-child(4) { animation-delay: 0.4s; }
.analysis-card:nth-child(5) { animation-delay: 0.5s; }
.analysis-card:nth-child(6) { animation-delay: 0.6s; }
.analysis-card:nth-child(7) { animation-delay: 0.7s; }
