/* =========================================
   1. RESET Y BASE
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }



body { 
    font-family: 'Inter', sans-serif; 
    overflow: hidden; 
    user-select: none; 
}



canvas { 
    touch-action: none; 
    outline: none; 
    display: block; 
}



/* =========================================
   2. COMPONENTES UI (PANELES)
   ========================================= */
.glass-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px); /* Safari */
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1), 0 4px 8px -2px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}



/* Modo Oscuro para Paneles */
.dark .glass-panel {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(51, 65, 85, 0.8);
    color: #cbd5e1;
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.3);
}



.coord-font { font-family: 'Roboto Mono', monospace; }



/* =========================================
   3. BOTONES E INPUTS
   ========================================= */

/* Botón Principal (Azul/Indigo) */
.btn-primary {
    background: linear-gradient(to right, #4f46e5, #4338ca); 
    transition: transform 0.1s, box-shadow 0.2s;
}


.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}


.btn-primary:active {
    transform: translateY(0);
}



/* Botones Pequeños (FIT, etc) - Reemplaza a .btn-mini */
.btn-mini {
    background-color: white;
    border: 1px solid #e2e8f0; /* slate-200 */
    border-radius: 0.25rem;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}


.btn-mini:hover {
    background-color: #eef2ff; /* indigo-50 */
    color: #4f46e5; /* indigo-600 */
}


.dark .btn-mini {
    background-color: #334155; /* slate-700 */
    border-color: #475569; /* slate-600 */
    color: #cbd5e1;
}


.dark .btn-mini:hover {
    background-color: #475569; /* slate-600 */
}



/* Botón Rojo Texto - Reemplaza a .btn-text-red */
.btn-text-red {
    font-size: 9px;
    color: #ef4444; /* red-500 */
    font-weight: 700;
    transition: color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
}


.btn-text-red:hover {
    color: #dc2626; /* red-600 */
}



/* Inputs Estándar - Reemplaza a .input-std */
.input-std {
    width: 100%;
    font-size: 0.75rem; /* text-xs */
    background-color: white;
    border: 1px solid #cbd5e1; /* slate-300 */
    border-radius: 0.5rem; /* rounded-lg */
    padding: 0.5rem;
    font-family: 'Roboto Mono', monospace;
    outline: none;
    transition: all 0.2s;
}


.input-std:focus {
    border-color: #6366f1; /* indigo-500 */
    box-shadow: 0 0 0 2px #c7d2fe; /* indigo-200 */
}


.dark .input-std {
    background-color: #1e293b; /* slate-800 */
    border-color: #475569; /* slate-600 */
    color: white;
}


.dark .input-std:focus {
    box-shadow: 0 0 0 2px #312e81; /* indigo-900 */
}



/* Inputs Pequeños (Snap) - Reemplaza a .input-mini */
.input-mini {
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    padding: 0.375rem;
    border-radius: 0.375rem;
    border: 1px solid #cbd5e1;
    background-color: white;
    outline: none;
    transition: all 0.2s;
}


.input-mini:focus {
    border-color: #f59e0b; /* amber-500 */
    box-shadow: 0 0 0 2px #fde68a; /* amber-200 */
}


.dark .input-mini {
    border-color: #475569;
    background-color: #334155;
    color: white;
}


.dark .input-mini:focus {
    box-shadow: 0 0 0 2px #78350f; /* amber-900 */
}



/* Etiquetas - Reemplaza a .lbl-input */
.lbl-input {
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 700;
    color: #64748b; /* slate-500 */
    margin-bottom: 0.25rem;
    display: block;
}


.dark .lbl-input {
    color: #94a3b8; /* slate-400 */
}



/* Encabezados Listas - Reemplaza a .lbl-header */
.lbl-header {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


.dark .lbl-header {
    color: #94a3b8;
}



/* =========================================
   4. TOGGLES (Interruptores)
   ========================================= */
.toggle-checkbox {
    appearance: none;
    position: absolute;
    opacity: 0;
}


.toggle-label {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #cbd5e1;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: inline-block;
}


.toggle-label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}


.dark .toggle-label {
    background-color: #475569;
}


.toggle-checkbox:checked + .toggle-label {
    background-color: #4f46e5;
}


.toggle-checkbox:checked + .toggle-label::after {
    transform: translateX(16px);
}



/* =========================================
   5. SCROLLBAR & ANIMACIONES
   ========================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }


::-webkit-scrollbar-track { background: transparent; }


::-webkit-scrollbar-thumb { 
    background: #cbd5e1; 
    border-radius: 10px; 
    transition: background 0.3s; 
}


::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


.dark ::-webkit-scrollbar-thumb { background: #475569; }


.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; }



.list-item:hover { transform: translateX(2px); }



@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }


    to { opacity: 1; transform: translateY(0); }


}
.fade-in { animation: fadeIn 0.3s ease; }



/* --- Estilos para la Barra de Herramientas "Más Bonita" --- */
.toolbar-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 12px; /* Radio un poco más cerrado */
    padding: 0.32rem;    /* Padding interno reducido */
    display: flex;
    flex-direction: column;
    gap: 0.32rem;        /* Espacio entre botones reducido */
    transition: all 0.3s ease;
}



.dark .toolbar-container {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(71, 85, 105, 0.5);
}



/* Botón de Herramienta Base */
.tool-btn {
    width: 2.25rem;  /* ANTES ERA 3rem. Ahora es 40px (Estándar) */
    height: 2.25rem; /* Igual altura */
    border-radius: 8px; /* Menos redondeado para verse más técnico */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    background: transparent;
}


/* Controlamos el tamaño del icono aquí para que no sea gigante */
.tool-btn i {
    font-size: 0.8rem; /* 16px - Tamaño normal */
    pointer-events: none;
}



.tool-btn:hover {
    background-color: rgba(241, 245, 249, 0.8); /* slate-100 */
    transform: translateY(-1px);
}


.dark .tool-btn:hover {
    background-color: rgba(51, 65, 85, 0.5);
    color: #e2e8f0;
}



/* --- Estado ACTIVO de Herramientas (Bonito) --- */
.tool-btn.active {
    background: linear-gradient(135deg, #4f46e5, #6366f1); /* indigo-600 -> indigo-500 */
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}



/* Diferentes colores por herramienta si quieres ser muy detallista */
.tool-btn.active[data-tool="select"] { background: linear-gradient(135deg, #4f46e5, #6366f1); }

 /* Indigo */
.tool-btn.active[data-tool="node"]   { background: linear-gradient(135deg, #3b82f6, #60a5fa); }

 /* Blue */
.tool-btn.active[data-tool="vector"] { background: linear-gradient(135deg, #f97316, #fb923c); }

 /* Orange */

/* --- Botones de Ajustes (Snap, Grid, Dark) --- */
.setting-btn {
    width: 2.25rem;  /* 40px */
    height: 2.25rem; /* 40px */
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    background: rgba(255,255,255,0.5);
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}


.setting-btn i {
    font-size: 0.8rem; /* Ajuste de icono */
}


.dark .setting-btn {
    background: rgba(30, 41, 59, 0.5);
    border-color: #475569;
    color: #64748b;
}



/* Activos de Ajustes */
.setting-btn.active-snap { background-color: #f59e0b; color: white; border-color: #d97706; box-shadow: 0 0 10px rgba(245, 158, 11, 0.3); }


.setting-btn.active-grid { background-color: #64748b; color: white; border-color: #475569; }


.setting-btn.active-dark { background-color: #7c3aed; color: white; border-color: #6d28d9; box-shadow: 0 0 10px rgba(124, 58, 237, 0.3); }



/* Input de Zoom Manual */
.input-zoom {
    background: transparent;
    border: none;
    color: #4f46e5;
    font-weight: bold;
    text-align: right;
    width: 4rem;
    outline: none;
    border-bottom: 1px dashed transparent;
    transition: border 0.2s;
}


.input-zoom:hover, .input-zoom:focus {
    border-bottom-color: #4f46e5;
}


.dark .input-zoom { color: #818cf8; }



.tool-btn.active[data-tool="load"] { background: linear-gradient(135deg, #ef4444, #f87171); }



/* Color activo para el botón Muelles (Spring) */
.tool-btn.active[data-tool="spring"] { 
    background: linear-gradient(135deg, #64748b, #94a3b8); /* slate-500 -> slate-400 */
    color: white;
}



.tool-btn.active[data-tool="pointLoad"] { 
    background: linear-gradient(135deg, #c026d3, #d946ef); 
    color: white;
}



.tool-btn.active[data-tool="barCond"] { 
    background: linear-gradient(135deg, #06b6d4, #22d3ee); 
    color: white;
}



.tool-btn.active[data-tool="table"] { 
    background: linear-gradient(135deg, #14b8a6, #2dd4bf); /* Teal */
    color: white;
}



/* Pestañas de Resultados */
.tab-res {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    border-radius: 6px 6px 0 0;
}



.tab-res:hover {
    color: #0f172a;
    background: #f1f5f9;
}



.tab-res.active {
    color: #10b981; /* Emerald-500 */
    border-bottom-color: #10b981;
    background: #ecfdf5;
}



/* Modo oscuro */
.dark .tab-res:hover { color: #f8fafc; background: #1e293b; }


.dark .tab-res.active { color: #34d399; border-bottom-color: #34d399; background: #064e3b; }



/* PESTAÑA DE EDITOR DE SECCIONES */
.sec-tab {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    color: #64748b;
    font-size: 14px;
    transition: all 0.2s;
    border: 1px solid transparent;
}


.sec-tab:hover {
    background-color: #f1f5f9;
    color: #4f46e5;
}


.sec-tab.active {
    background-color: #eef2ff;
    color: #4f46e5;
    border-color: #c7d2fe;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}


.dark .sec-tab:hover {
    background-color: #1e293b;
    color: #818cf8;
}


.dark .sec-tab.active {
    background-color: #312e81; /* indigo-900 */
    color: #a5b4fc;
    border-color: #4338ca;
}



/* Sidebar Nav Buttons */
.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s;
    text-align: left;
}


.nav-btn:hover {
    background: #f1f5f9;
    color: #334155;
}


.dark .nav-btn:hover {
    background: #1e293b;
    color: #cbd5e1;
}


.nav-btn.active {
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}


.dark .nav-btn.active {
    background: #312e81;
    color: #a5b4fc;
    border-color: #4f46e5;
}



/* Shape Grid Buttons */
.shape-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    font-size: 16px;
    transition: all 0.2s;
}


.shape-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #eef2ff;
}


.dark .shape-btn {
    background: #1e293b;
    border-color: #334155;
}



/* Navegación Lateral (Iconos) */
.nav-icon-btn {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8;
    background: transparent;
    transition: all 0.2s;
    position: relative;
    font-size: 18px;
}


.nav-icon-btn:hover { background: #e2e8f0; color: #475569; }


.nav-icon-btn.active { background: #6366f1; color: white; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4); }



/* Inputs en el panel */
.input-std {
    width: 100%; height: 32px;
    background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 6px; padding: 0 10px;
    font-size: 12px; color: #334155;
    outline: none; transition: border 0.2s;
}



/* Grid Canvas */
.cursor-crosshair { cursor: crosshair; }




/* --- ESTILOS PARA EL REPORTE DE CÁLCULO --- */
.report-header {
    border-bottom: 2px solid #0f172a;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}


.report-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
}


.report-meta {
    text-align: right;
    font-size: 0.75rem;
    color: #64748b;
}


.report-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    border-left: 4px solid #4f46e5;
    padding-left: 0.75rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    background: #f8fafc;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}


.math-block {
    background-color: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    margin: 1rem 0;
    font-family: 'Times New Roman', serif;
    font-style: italic;
    font-size: 1.1rem;
    text-align: center;
    color: #334155;
}


.calc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin: 1rem 0;
    font-family: 'Roboto Mono', monospace;
}


.calc-table th {
    background-color: #f1f5f9;
    border-bottom: 2px solid #cbd5e1;
    padding: 0.5rem;
    text-align: center;
    font-weight: 700;
    color: #475569;
}


.calc-table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 0.4rem;
    text-align: center;
    color: #334155;
}


.calc-table tr:last-child td {
    border-bottom: 2px solid #0f172a;
    font-weight: 700;
    background-color: #f8fafc;
}


.report-diagram {
    display: block;
    margin: 2rem auto;
    max-width: 300px;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem;
    background: white;
}


@media print {
    .glass-panel, .toolbar-container, aside { display: none !important; }


    #reportModal { position: static; background: white; width: 100%; height: auto; }


    .no-print { display: none; }
}

