:root {
    --primary-color: #2563eb; /* Blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #10B981; /* Emerald */
    --bg-main: #F3F4F6; /* Light gray */
    --bg-card: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    
    /* Dark Mode Tokens */
    --dark-bg-main: #111827;
    --dark-bg-card: #1F2937;
    --dark-text-main: #F9FAFB;
    --dark-text-muted: #9CA3AF;
    --dark-border-color: #374151;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 300ms ease-in-out;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

body.dark-mode {
    --bg-main: var(--dark-bg-main);
    --bg-card: var(--dark-bg-card);
    --text-main: var(--dark-text-main);
    --text-muted: var(--dark-text-muted);
    --border-color: var(--dark-border-color);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    transition: background-color var(--transition-normal);
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: -0.025em;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.nav-link i {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border-radius: var(--radius-lg);
    padding: 0.5rem 1rem;
    width: 400px;
    border: 1px solid var(--border-color);
    transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-main);
    width: 100%;
    margin-left: 0.5rem;
    font-family: inherit;
}

/* En escritorio el boton hamburguesa esta display:none y era el unico hermano
   que empujaba las acciones a la derecha con space-between. */
.header-actions {
    margin-left: auto;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color var(--transition-fast);
}

.theme-toggle:hover {
    background-color: var(--bg-main);
    color: var(--primary-color);
}

.content-body {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Cards & Elements */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.4);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-main);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:hover td {
    background-color: rgba(37, 99, 235, 0.02);
}

/* Chatbot Styles */
.chatbot-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    border: none;
    transition: transform var(--transition-fast);
}

.chatbot-toggle:hover {
    transform: scale(1.05);
}

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chatbot-window.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.chatbot-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.chatbot-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--bg-main);
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--bg-card);
    color: var(--text-main);
    border-bottom-left-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

.message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chatbot-input {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-card);
}

.chatbot-input input {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    outline: none;
    font-family: inherit;
}

.chatbot-input input:focus {
    border-color: var(--primary-color);
}

.chatbot-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
}

.chatbot-input button:hover {
    background-color: var(--primary-hover);
}

/* Glassmorphism elements if needed */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}
body.dark-mode .glass {
    background: rgba(31, 41, 51, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Accordion Component */
.carrera-accordion {
    margin-bottom: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.carrera-btn {
    width: 100%;
    text-align: left;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color var(--transition-fast);
    box-sizing: border-box;
}

.carrera-btn:hover {
    background-color: var(--primary-hover);
}

.carrera-content {
    display: none;
    padding: 0;
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* ==========================================================================
   Responsive / mobile
   El sidebar fijo de 260px y los paddings de 2-3rem se superponen en celular.
   Debajo de 900px el sidebar pasa a ser un drawer con hamburguesa + backdrop.
   ========================================================================== */

.menu-toggle,
.sidebar-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-main);
        font-size: 1.35rem;
        padding: 0.5rem 0.75rem;
        margin-left: -0.75rem;
        cursor: pointer;
        border-radius: var(--radius-md);
    }

    .menu-toggle:hover {
        background-color: var(--bg-main);
        color: var(--primary-color);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 82vw;
        z-index: 1100;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal);
    }

    .sidebar-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    body.nav-open {
        overflow: hidden;
    }

    /* Dedo, no mouse: los links del menu necesitan area de toque */
    .nav-link {
        padding: 0.9rem 1rem;
    }

    .header {
        height: 60px;
        padding: 0 1rem;
    }

    .content-body {
        padding: 1rem;
    }

    /* Los templates traen los grids y paddings como style="" inline, que gana
       por especificidad: sin !important el layout de escritorio sobrevive.
       ponytail: si aparecen mas casos, mover esos inline a clases .grid-2 / .modal. */
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    [style*="justify-content: space-between"] {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* :not(...) respeta las cards que a proposito van a padding 0 (tablas a borde) */
    .card:not([style*="padding: 0"]) {
        padding: 1.25rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .btn {
        padding: 0.55rem 0.9rem;
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }

    .chatbot-widget {
        bottom: 1rem;
        right: 1rem;
    }

    .chatbot-toggle {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
    }

    /* Anclado al viewport, no al boton: 350px fijos se salen de pantalla */
    .chatbot-window {
        position: fixed;
        left: 1rem;
        right: 1rem;
        bottom: 5rem;
        width: auto;
        height: min(70vh, 460px);
    }
}

@media (max-width: 480px) {
    .sidebar-logo {
        font-size: 1.25rem;
    }

    .header {
        padding: 0 0.75rem;
    }

    .content-body {
        padding: 0.75rem;
    }

    /* El avatar del header no aporta nada y le roba ancho al boton Salir */
    .header-actions > div > div:first-child {
        display: none !important;
    }
}

/* Confirmacion de acciones del asistente: el chat frena antes de tocar la base */
.chat-confirm {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-confirm code {
    display: block;
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.6rem;
}

.chat-confirm-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-confirm-actions .btn {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}
