/* css/main.css */
:root {
    /* Color Palette - Red/White Corporate Theme */
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --input-focus-bg: #eff6ff;
    --border-color: #e2e8f0;

    --primary-color: #006ce4;
    /* Edite Premium Blue */
    --primary-hover: #0056b3;
    --accent-blue: #0ea5e9;
    /* Brighter blue for accents */

    --text-color: #0f172a;
    --text-muted: #64748b;

    --sidebar-bg: #ffffff;
    --sidebar-text: #334155;
    --sidebar-border: #e2e8f0;

    --sidebar-width: 260px;
    --header-height: 60px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

/* Layout Dashboard */
.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
    z-index: 1000;
    transition: transform 0.3s ease, width 0.05s linear;
}

/* Resize Handle */
.sidebar-resizer {
    position: absolute;
    right: -3px;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 1001;
}

.sidebar-resizer:hover,
.is-resizing .sidebar-resizer {
    background-color: var(--primary-color);
    opacity: 0.3;
}

/* Resizing State */
body.is-resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

body.is-resizing .sidebar,
body.is-resizing .main-content {
    transition: none !important;
}

/* Responsive Sidebar Mobile */
@media (max-width: 1024px) {
    .sidebar-resizer { display: none; }
    .sidebar {
        transform: translateX(-100%);
        width: 260px !important;
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.25rem;
}

.sidebar-logo {
    width: 140px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sidebar-logo img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1.2;
    color: #1e40af; 
    letter-spacing: -0.5px;
}

.sidebar-title span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
}

.sidebar-menu li {
    padding: 0.25rem 1rem;
}

.sidebar-menu .menu-divider {
    font-size: 0.75rem;
    font-weight: 800;
    color: #b91c1c; /* Corporate Red */
    text-transform: uppercase;
    padding: 1.5rem 1rem 0.5rem 1rem;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    gap: 0.75rem;
    font-weight: 500;
    overflow: hidden; /* Evita que el texto rompa el layout */
    white-space: nowrap; /* Mantiene el texto en una línea */
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.sidebar-menu a.active {
    border-left: 3px solid var(--primary-color);
}

.sidebar-menu svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0; /* IMPRESCINDIBLE: Evita que el icono desaparezca al reducir ancho */
}

.sidebar-footer {
    margin-top: auto;
    padding: 1.5rem;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #eff6ff;
    color: var(--primary-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-details {
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    color: var(--text-color);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    background-color: transparent;
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    text-decoration: none;
    font-weight: 500;
}

.btn-logout:hover {
    background-color: #eff6ff;
    color: var(--primary-color);
    border-color: #bfdbfe;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2.5rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    width: calc(100% - var(--sidebar-width));
    box-sizing: border-box;
    position: relative;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 108, 228, 0.4);
}

.mobile-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: flex;
    }

    .mobile-close {
        display: block;
        margin-left: auto;
    }

    .sidebar-header {
        justify-content: flex-start;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 4.5rem 1.5rem 1.5rem 1.5rem;
    }

    .page-header {
        padding-left: 3rem; /* Espacio extra para el botón hamburguesa */
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 1rem;
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
}

.page-title p {
    margin: 0.5rem 0 0 0;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 108, 228, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(0, 108, 228, 0.3);
}

.btn-primary svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

a.stat-card {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    border-color: #fca5a5;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-icon.primary {
    background: #eff6ff;
    color: var(--primary-color);
}

.stat-icon.success {
    background: #d1fae5;
    color: #059669;
}

.stat-icon.warning {
    background: #fef3c7;
    color: #d97706;
}

.stat-icon.danger {
    background: #fee2e2;
    color: #dc2626;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Animations */
@keyframes fadeInBody {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Sidebar Izquierdo (Módulo Formación Profesional) --- */
.fp-sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-height));
}

.fp-menu {
    list-style: none;
    padding: 0 15px;
}

.fp-menu li {
    position: relative;
    margin-bottom: 5px;
}

.fp-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s;
}

.fp-menu a:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.fp-menu a.active {
    background: #f1f5f9;
    color: var(--primary-color);
    font-weight: 700;
}

.fp-menu-icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

/* Submenú (Flyout) */
.fp-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px;
    z-index: 1000;
    width: 220px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    list-style: none;
    margin-left: 5px;
}

.fp-submenu::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 15px;
    width: 10px;
    height: 10px;
    background: white;
    border-left: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transform: rotate(45deg);
}

.fp-menu li:hover .fp-submenu {
    display: block;
}

.fp-submenu li {
    margin-bottom: 2px;
}

.fp-submenu a {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    background: #fff !important;
    color: #1e293b !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fp-submenu a:hover {
    background: #f1f5f9 !important;
    color: var(--primary-color) !important;
}

.fp-submenu a.active {
    background: #e2e8f0 !important;
    color: #1e293b !important;
    font-weight: 600;
}

.submenu-icon {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* Layout específico para FP */
.fp-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - var(--header-height));
    background: #f8fafc;
}

.fp-content-main {
    flex: 1;
    min-width: 0; /* Permite que el flex item se encoja correctamente */
    padding: 30px;
    overflow-x: hidden; /* Evita que la sección principal cree scroll extraño */
}