body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; display: flex; background-color: #f8f9fa; }
#sidebar { 
    width: 280px; 
    background-color: #343a40; /* Darker sidebar */
    color: white;
    padding: 20px; 
    height: 100vh; 
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}
#sidebar h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #495057;
    padding-bottom: 0.75rem;
}
#sidebar ul { list-style: none; padding: 0; }
#sidebar li { margin-bottom: 0.5rem; }
#sidebar button {
    width: 100%;
    padding: 0.85rem 1rem; /* Increased padding */
    border: none;
    border-radius: 0.375rem; /* Bootstrap's default rounded corners */
    background: #495057; /* Slightly lighter than sidebar bg */
    color: white;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
    text-align: left; /* Align text to the left */
}
#sidebar button:hover, #sidebar button.active {
    background: #007bff; /* Bootstrap primary blue */
    transform: translateX(5px);
}

#content { 
    margin-left: 280px; /* Same as sidebar width */
    flex-grow: 1; 
    padding: 30px;  /* Increased padding */
    overflow-y: auto; /* Allow content to scroll if needed */
    height: 100vh;
}
.tool-container { 
    background-color: #fff; 
    border: 1px solid #dee2e6; 
    border-radius: 0.375rem; 
    padding: 30px; /* Increased padding */
    margin-top: 0; /* Removed top margin as content has padding */
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

/* Common input styles */
.matrix-input input, .number-input, .operation-selector { 
    width: 100%; 
    padding: 0.5rem; 
    border: 1px solid #ced4da; 
    border-radius: 0.25rem; 
    text-align: center; 
    font-size: 1rem;
    box-sizing: border-box; /* Important for width 100% */
}
/* Specific style for matrix entry cells in general */
.matrix-entry-cell {
    width: 80px; /* Adjust as needed for fractions */
    margin: 2px;
}
.matrix-input input { width: 80px; margin: 2px; } /* Specific to Gauss-Jordan if needed */


.gj-history { max-height: 200px; overflow-y: auto; }
.gj-card { margin-bottom: 1rem; }
.gj-matrix { font-size: 0.9em; white-space: pre-wrap; }

.btn-primary { background-color: #007bff; border-color: #007bff; }
.btn-primary:hover { background-color: #0056b3; border-color: #0056b3; }
.btn-secondary { background-color: #6c757d; border-color: #6c757d; }
.btn-secondary:hover { background-color: #545b62; border-color: #545b62; }
.btn-warning { background-color: #ffc107; border-color: #ffc107; color: #212529; }
.btn-warning:hover { background-color: #e0a800; border-color: #d39e00; }
.btn-success { background-color: #28a745; border-color: #28a745; }
.btn-danger { background-color: #dc3545; border-color: #dc3545; }


/* Estilos específicos para la herramienta de determinantes */
:root {
    --primary-color-det: #007bff;      /* Bootstrap primary */
    --secondary-color-det: #6c757d;   /* Bootstrap secondary */
    --warning-color-det: #ffc107;     /* Bootstrap warning */
    --danger-color-det: #dc3545;      /* Bootstrap danger */
    --border-color-det: #dee2e6;      /* Bootstrap border */
    --background-light-det: #f8f9fa;  /* Bootstrap light background */
}

.determinant-tool .main-title { font-size: 1.8rem; font-weight: bold; text-align: center; margin-bottom: 2rem; color: #343a40; }
.determinant-tool .subtitle { font-size: 1.25rem; font-weight: 600; margin: 1.5rem 0 1rem 0; color: #495057; border-bottom: 1px solid var(--border-color-det); padding-bottom: 0.5rem;}

.determinant-tool .grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}

.determinant-tool .card { 
    background: white; 
    border-radius: 0.375rem; 
    padding: 20px; 
    border: 1px solid var(--border-color-det);
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
}

.matrix-grid-det { display: grid; gap: 0.5rem; margin: 1rem 0; }
.matrix-row-det { display: flex; gap: 0.5rem; justify-content: center; }
.matrix-cell-det { position: relative; min-width: 60px; max-width: 70px; } /* Adjusted width */

.determinant-tool .button { 
    display: inline-block; padding: 0.65rem 1rem; border: none; border-radius: 0.25rem; 
    font-size: 0.95rem; cursor: pointer; transition: background-color 0.2s; 
    text-align: center; width: 100%; margin: 0.5rem 0; color: white; font-weight: 500;
}
.button-primary-det { background-color: var(--primary-color-det); }
.button-primary-det:hover { background-color: #0056b3; }
.button-secondary-det { background-color: var(--secondary-color-det); }
.button-secondary-det:hover { background-color: #545b62; }
.button-warning-det { background-color: var(--warning-color-det); color: #212529; }
.button-warning-det:hover { background-color: #e0a800; }
.button-danger-det { background-color: var(--danger-color-det); }
.button-danger-det:hover { background-color: #b02a37; }


.process-section-det { margin-top: 20px; padding: 15px; background-color: var(--background-light-det); border-radius: 0.375rem; border: 1px solid var(--border-color-det); }
.latex-process-det { 
    margin: 10px 0; padding: 20px; background-color: white; border-radius: 0.25rem; 
    min-height: 150px; overflow-x: auto; border: 1px solid var(--border-color-det); 
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); font-size: 1.1em;
}
.operations-box-det { padding: 15px; background-color: var(--background-light-det); border-radius: 0.375rem; margin: 1rem 0; border: 1px solid var(--border-color-det); }
.operation-inputs-det { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.operation-inputs-det div { display: flex; flex-direction: column; } /* Stack label and select/input */
.operation-inputs-det label { margin-bottom: 0.25rem; font-weight: 500; font-size: 0.9em; }

.info-section-det { margin-top: 1.5rem; padding: 1rem; background-color: #e9ecef; border-radius: 0.25rem; border-left: 4px solid var(--primary-color-det); font-size: 0.9em;}
.properties-section-det { margin-top: 1.5rem; padding: 1rem; background-color: #e9ecef; border-radius: 0.25rem; }
.property-item-det { margin-bottom: 0.75rem; padding: 0.75rem; border-left: 3px solid var(--primary-color-det); background-color: white; border-radius: 0.25rem; }
.property-item-det p { margin-bottom: 0.25rem; font-size: 0.9em; }
.property-item-det strong { font-size: 0.95em; }

.button:disabled { background-color: #ccc; cursor: not-allowed; }
.final-determinant-display {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #d1ecf1; /* Light blue for info */
    border: 1px solid #bee5eb;
    color: #0c5460; /* Darker blue text */
    border-radius: 0.25rem;
    font-weight: bold;
    text-align: center;
    font-size: 1.2em;
}

/* Estilos para matrices */
.matrix-container {
    margin: 1rem 0;
}
.latex-output {
    margin-top: 1.5rem;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    word-wrap: break-word; /* NUEVO: para que el LaTeX no se desborde tanto */
    overflow-x: auto; /* NUEVO: scroll si es necesario */
}

/* Estilos mejorados para visualización LaTeX */
.latex-output {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mejoras específicas para la visualización de LaTeX y MathJax */
.latex-output .MathJax_Display,
.formula-panel .MathJax_Display,
.math .MathJax_Display {
    margin: 1em 0 !important;
    text-align: center !important;
}

.latex-output .MathJax,
.formula-panel .MathJax,
.math .MathJax {
    font-size: 1.2em !important;
    line-height: 1.4 !important;
}

/* Forzar re-renderizado correcto de MathJax */
.math-equation .MathJax_Display,
.formula-panel .MathJax_Display,
.math .MathJax_Display {
    margin: 0.5em 0 !important;
}

/* Mejorar visualización de fórmulas LaTeX */
.latex-output, .formula-panel, .math {
    overflow-x: auto;
    padding: 10px 0;
    max-width: 100%;
}

/* Estilos específicos para símbolos matemáticos y facilitar visualización */
.MathJax .math {
    font-size: 1.15em !important;
}

.MathJax_SVG_Display, .MathJax_Display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 0;
}

/* Estilos para alternativas CSS Grid y SVG para casos matemáticos */

/* Grid alternative para \begin{cases} */
.cases-grid {
    display: inline-flex;
    align-items: center;
    margin: 10px 0;
    position: relative;
    font-size: 1.1em;
}

.cases-grid::before {
    content: "";
    width: 12px;
    height: 100%;
    background: linear-gradient(to bottom, transparent 0%, black 2%, black 48%, transparent 50%, transparent 52%, black 98%, transparent 100%);
    border-left: 3px solid black;
    border-top: 3px solid black;
    border-bottom: 3px solid black;
    border-radius: 8px 0 0 8px;
    margin-right: 10px;
    min-height: 60px;
}

.cases-grid-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 5px 0;
}

.cases-eq {
    display: block;
    padding: 4px 0;
    font-family: 'Times New Roman', serif;
    font-size: 1.1em;
    line-height: 1.4;
}

/* SVG alternative para \begin{cases} */
.cases-svg {
    display: inline-flex;
    align-items: center;
    margin: 10px 0;
    position: relative;
    font-size: 1.1em;
}

.cases-svg-brace {
    width: 20px;
    margin-right: 10px;
    height: auto;
}

.cases-svg-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.cases-row {
    display: flex;
    align-items: center;
    min-height: 25px;
}

.cases-equation {
    font-family: 'Times New Roman', serif;
    font-size: 1.1em;
    line-height: 1.4;
}

/* Estilos específicos para ecuaciones paramétricas */
.parametric-equation-container {
    display: inline-block;
    margin: 15px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e9ecef;
}

.parametric-equation-container .cases-grid,
.parametric-equation-container .cases-svg {
    background: white;
    padding: 10px;
    border-radius: 3px;
}

/* Simple square root styling */
.sqrt-simple {
    position: relative;
    display: inline-block;
    padding-left: 1.2em;
    padding-top: 0.3em;
    font-style: normal;
}

.sqrt-simple::before {
    content: "√";
    position: absolute;
    left: 0;
    top: 0.05em;
    font-size: 1.2em;
    font-weight: bold;
    color: currentColor;
}

.sqrt-simple::after {
    content: "";
    position: absolute;
    left: 1.1em;
    top: 0.2em;
    right: 0;
    height: 2px;
    background-color: currentColor;
}

/* Alternative square root with better styling */
.sqrt-symbol {
    position: relative;
    display: inline-block;
    padding-left: 1.5em;
    padding-top: 0.3em;
    margin-right: 0.2em;
}

.sqrt-symbol::before {
    content: "√";
    position: absolute;
    left: 0.1em;
    top: 0.1em;
    font-size: 1.4em;
    font-weight: bold;
    color: currentColor;
    line-height: 1;
}

.sqrt-symbol::after {
    content: "";
    position: absolute;
    left: 1.4em;
    top: 0.25em;
    right: 0;
    height: 2px;
    background-color: currentColor;
}

/* Math equation container improvements */
.math-equation {
    font-size: 1.1em;
    line-height: 1.6;
    margin: 1em 0;
    text-align: center;
}

.math-equation .sqrt-simple,
.math-equation .sqrt-symbol {
    font-size: 1em;
    vertical-align: baseline;
}

/* Inline math with sqrt */
.inline-math .sqrt-simple,
.inline-math .sqrt-symbol {
    font-size: 0.95em;
    padding-top: 0.25em;
}

.inline-math .sqrt-simple::after,
.inline-math .sqrt-symbol::after {
    height: 1.5px;
}

/* =================================
   GEOGEBRA INTEGRATION STYLES
   ================================= */

/* GeoGebra main container */
.geogebra-tool {
    background: #ffffff;
    border-radius: 12px;
    padding: 0;
    margin: 0;
}

/* GeoGebra main title */
.geogebra-tool .main-title {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 3px solid #3498db;
    padding-bottom: 1rem;
}

/* GeoGebra cards styling */
.geogebra-card {
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.geogebra-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: #3498db;
}

.geogebra-card .card-body {
    padding: 2rem;
}

.geogebra-card .card-title {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 1rem;
}

.geogebra-card .card-text {
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Badge styling for GeoGebra cards */
.geogebra-card .badge {
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
}

.geogebra-card .badge-primary {
    background-color: #3498db;
    color: white;
}

.geogebra-card .badge-success {
    background-color: #27ae60;
    color: white;
}

.geogebra-card .badge-warning {
    background-color: #f39c12;
    color: white;
}

/* GeoGebra container for the applet */
#geogebra-container {
    margin-top: 2rem;
    animation: fadeIn 0.5s ease-in;
}

#geogebra-container .card {
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
}

#geogebra-container .card-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 1rem 1.5rem;
    border-bottom: none;
}

#geogebra-container .card-header h5 {
    margin: 0;
    font-weight: 600;
}

#geogebra-container .card-header .btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    transition: all 0.2s ease;
}

#geogebra-container .card-header .btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

/* GeoGebra applet container */
#geogebra-applet {
    background: #f8f9fa;
    border-radius: 0;
    overflow: hidden;
    position: relative;
}

#geogebra-applet iframe {
    border: none;
    width: 100%;
    height: 100%;
}

/* Loading animation for GeoGebra */
.geogebra-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 600px;
    background: #f8f9fa;
    flex-direction: column;
}

.geogebra-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    color: #3498db;
}

.geogebra-loading p {
    margin-top: 1rem;
    color: #6c757d;
    font-size: 1.1rem;
}

/* Alert styling for GeoGebra info */
.geogebra-tool .alert-info {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 1px solid #2196f3;
    border-radius: 10px;
    padding: 1.5rem;
}

.geogebra-tool .alert-info h5 {
    color: #1565c0;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.geogebra-tool .alert-info p {
    color: #1976d2;
    margin: 0;
}

/* Tips card styling */
.geogebra-tool .card:last-child {
    background: linear-gradient(135deg, #fff9c4, #fff59d);
    border: 1px solid #ffc107;
}

.geogebra-tool .card:last-child .card-title {
    color: #f57f17;
}

.geogebra-tool .card:last-child li {
    margin-bottom: 0.5rem;
    color: #f57f17;
}

/* Icons styling */
.geogebra-card i {
    margin-bottom: 1rem;
}

.text-primary { color: #3498db !important; }
.text-success { color: #27ae60 !important; }
.text-warning { color: #f39c12 !important; }

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

/* Responsive design for GeoGebra */
@media (max-width: 768px) {
    .geogebra-card .card-body {
        padding: 1.5rem;
    }
    
    .geogebra-tool .main-title {
        font-size: 1.5rem;
    }
    
    #geogebra-applet {
        height: 400px !important;
    }
    
    .geogebra-card:hover {
        transform: none;
    }
}

@media (max-width: 576px) {
    .geogebra-card .card-body {
        padding: 1rem;
    }
    
    .geogebra-tool .main-title {
        font-size: 1.3rem;
    }
    
    #geogebra-applet {
        height: 350px !important;
    }
}

/* Error message styling for GeoGebra */
#geogebra-applet .alert-danger {
    border-radius: 10px;
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    border: 1px solid #f44336;
    color: #c62828;
}

#geogebra-applet .alert-danger h5 {
    color: #d32f2f;
    font-weight: 600;
}

#geogebra-applet .alert-danger .btn-primary {
    background: #f44336;
    border-color: #f44336;
}

#geogebra-applet .alert-danger .btn-primary:hover {
    background: #d32f2f;
    border-color: #d32f2f;
}
