/* =========================
   BASE
========================= */
html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    color: white;
    background: linear-gradient(180deg, #0A192F 0%, #0F172A 100%);
}

/* Contenido principal ocupa espacio y deja margen inferior */
main {
    flex: 1;
    position: relative;
    z-index: 3;
    padding-bottom: 2rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Footer pegado abajo */
.footer {
    flex-shrink: 0;
    padding: 1rem;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
    color: white;
    text-align: center;
    z-index: 5;
    font-size: 0.95rem;
}

/* =========================
   HOME OVERLAY
========================= */
.no-scroll {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.site-overlay {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.overlay {
    background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(0,0,50,0.6));
    padding: 20px 40px;
    border-radius: 10px;
    animation: gradientShift 8s ease infinite;
    color: white;
    text-align: center;
    max-width: 450px;
    width: 100%;
}

@keyframes gradientShift {
    0% {
        background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(0,0,50,0.6));
    }

    50% {
        background: linear-gradient(135deg, rgba(0,0,50,0.6), rgba(0,50,100,0.6));
    }

    100% {
        background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(0,0,50,0.6));
    }
}

/* Overlay responsive */
@media (max-width: 576px) {
    .overlay {
        padding: 15px 25px;
    }
}

/* =========================
   TIPOGRAFÍA
========================= */
.title {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    text-shadow: 0 0 15px #00f0ff;
}

.subtitle {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/* Media queries para tipografía responsive */
@media (max-width: 576px) {
    .title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    .title {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 1.2rem;
    }
}

/* =========================
   BOTONES
========================= */
.btn-primary {
    background: linear-gradient(90deg, #00f0ff, #0077ff);
    border: none;
    box-shadow: 0 0 10px #00f0ff;
    transition: all 0.3s ease;
}

    .btn-primary:hover {
        box-shadow: 0 0 20px #00f0ff, 0 0 40px #0077ff;
        transform: scale(1.05);
    }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Botones responsive */
@media (max-width: 576px) {
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-primary, .btn-secondary, .btn-danger, .btn-success {
        width: 100%;
    }

    .btn-group-vertical {
        width: 100%;
    }

    /* Menu button: no expandir a ancho completo */
    #menu-btn {
        width: auto !important;
        min-width: 44px;
        padding: 0.5rem 0.75rem !important;
    }
}

/* =========================
   VIDEO BACKGROUND
========================= */
#bg-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

@media (max-width: 768px) {
    #bg-video {
        display: block;
    }

    body {
        background: linear-gradient(180deg, #0A192F 0%, #0F172A 100%) !important;
        background-attachment: fixed;
    }
}

/* =========================
   HEADER / NAVBAR
========================= */
header {
    flex-shrink: 0;
    padding: 0;
    height: 60px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
    color: white;
    z-index: 5;
}

.navbar-brand, .nav-link, footer a {
    color: white !important;
}

.navbar-brand {
    font-size: 1.25rem;
}

.navbar-toggler {
    border-color: rgba(255,255,255,0.5);
    padding: 0.25rem 0.5rem;
}

.navbar-toggler-icon {
    filter: invert(1);
}

/* Collapse menú mobile */
@media (max-width: 767px) {
    .navbar-collapse.show {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(0,0,0,0.8);
        padding: 15px;
        z-index: 1120;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    header {
        height: 50px;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1rem;
    }
}

/* =========================
   SIDEBAR
========================= */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    padding-top: 60px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1200;
    box-shadow: 2px 0 15px rgba(0,0,0,0.5);
    overflow-y: auto;
}

    #sidebar.active {
        transform: translateX(0);
    }

    #sidebar a {
        display: block;
        padding: 15px 25px;
        color: white;
        text-decoration: none;
        font-size: 16px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        transition: background 0.2s;
        word-wrap: break-word;
    }

        #sidebar a:hover {
            background: rgba(255,255,255,0.05);
        }

#close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 30px;
    cursor: pointer;
    z-index: 1;
}

/* Sidebar responsive para móviles */
@media (max-width: 576px) {
    #sidebar {
        width: 100%;
        max-width: 80vw;
    }

    #sidebar a {
        padding: 12px 20px;
        font-size: 14px;
    }

    #close-btn {
        font-size: 24px;
    }
}

/* =========================
   HELPERS
========================= */
.form-bottom-space {
    margin-bottom: 4rem; /* más espacio para botones de submit */
}

/* Estilo global para todas las tablas */
.table {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    color: white;
    font-size: 0.95rem;
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 0;
    border: none;
}

    /* Encabezados */
    .table thead th {
        background: rgba(255,255,255,0.1);
        color: #00f0ff;
        font-weight: 600;
        text-transform: uppercase;
        padding: 12px;
        font-size: 0.85rem;
        border: none;
    }

/* Filas alternadas */
.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255,255,255,0.05);
}

/* Hover elegante */
.table tbody tr:hover {
    background: rgba(255,255,255,0.15);
    transition: background 0.2s ease;
}

/* Celdas */
.table td, .table th {
    border: none !important;
    border-bottom: none !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    padding: 12px;
}

/* Tablas responsive: horizontal scroll en móviles */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    display: block;
    width: 100%;
}

.table-wrapper .table {
    width: 100%;
    table-layout: auto;
}

@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .table {
        font-size: 0.85rem;
        margin-bottom: 0;
    }

        .table thead th {
            padding: 8px;
            font-size: 0.75rem;
        }

        .table td {
            padding: 8px;
        }
}

@media (max-width: 576px) {
    .table {
        font-size: 0.8rem;
    }

        .table thead th {
            padding: 6px;
            font-size: 0.7rem;
        }

        .table td {
            padding: 6px;
        }

    .table-hide-xs {
        display: none !important;
    }

    .table-hide-sm {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .table-hide-md {
        display: none !important;
    }
}

/* =========================
   FORMULARIOS COMPACTOS
========================= */

/* Labels e inputs en línea */
.form-label {
    display: inline-block;
    width: 70px;
    margin-right: 1rem;
    text-align: left;
    margin-bottom: 0;
}

/* Inputs más angostos */
.form-control {
    display: inline-block;
    width: 100%; /* que no ocupen todo el ancho */
    max-width: 500px; /* límite razonable */
}

/* Selects más compactos */
.form-select {
    display: inline-block;
    width: 100%;
    max-width: 500px;
    margin-left: 20px;
}

textarea.form-control {
    display: inline-block;
    width: 100%;
    max-width: 1200px;
    margin-left: 20px;
}

/* Formularios responsive para móviles */
@media (max-width: 768px) {
    .form-label {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 0.5rem;
        text-align: left;
    }

    .form-control {
        display: block;
        max-width: 100%;
        margin-left: 0;
        margin-bottom: 1rem;
    }

    .form-select {
        display: block;
        max-width: 100%;
        margin-left: 0;
        margin-bottom: 1rem;
    }

    textarea.form-control {
        display: block;
        max-width: 100%;
        margin-left: 0;
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    .form-control,
    .form-select,
    textarea.form-control {
        font-size: 16px; /* previene zoom en iOS */
    }

    .mb-3 {
        margin-bottom: 1rem !important;
    }
}

/* Chatbot flotante */
#chatbot-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 300px;
    background: white;
    color: black;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 14px;
    overflow: hidden;
    z-index: 2000;
}

/* Header */
#chatbot-header {
    background: #0A192F;
    color: white;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
}

    #chatbot-header .chatbot-title {
        margin-left: 8px;
    }

    #chatbot-header .status-dot {
        width: 10px;
        height: 10px;
        background: #00ff00;
        border-radius: 50%;
        display: inline-block;
    }

/* Botón minimizar */
#chatbot-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

/* Cuerpo */
#chatbot-body {
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

#chat-window {
    overflow-x: hidden;
    margin-bottom: 10px;
    word-wrap: break-word;
}

#chatbot-input-area {
    display: flex;
    gap: 6px;
    align-items: center;
}

#chat-input {
    flex: 1; /* ocupa el espacio disponible */
    min-width: 0; /* evita que desborde el contenedor */
}

#chat-send {
    flex-shrink: 0; /* el botón no se achica */
}

/* Chatbot responsive */
@media (max-width: 768px) {
    #chatbot-container {
        width: calc(100vw - 40px);
        max-width: 350px;
        bottom: 70px;
        right: 20px;
    }
}

@media (max-width: 576px) {
    #chatbot-container {
        width: calc(100vw - 20px);
        max-width: 100%;
        bottom: 60px;
        right: 10px;
        left: 10px;
    }

    #chatbot-body {
        max-height: 300px;
    }
}

/* =========================
   MODAL
========================= */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1055;
}

.modal-backdrop {
    z-index: 1050;
}

.modal-dialog-centered {
    min-height: calc(100% - 1rem);
}

.modal-content {
    background: rgba(10, 25, 47, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 240, 255, 0.2);
    color: white;
    border-radius: 10px;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
    color: #00f0ff;
    font-weight: 600;
}

.hover-underline:hover {
    text-decoration: underline;
}

/* =========================
   DASHBOARD FLOATING
========================= */
.dashboard-floating {
    position: relative;
    z-index: 3;
}

.dashboard-panel {
    background: linear-gradient(145deg, rgba(7, 20, 42, 0.86), rgba(5, 13, 30, 0.92));
    border: 1px solid rgba(0, 240, 255, 0.22);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color: #f2f7ff;
    padding: 1.25rem;
}

.dashboard-kpi-title {
    color: #8ed7ff;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

.dashboard-muted {
    color: #b5d1ea;
}

.dashboard-table {
    background: transparent;
}

.dashboard-table thead th {
    background: rgba(0, 0, 0, 0.35);
}

.dashboard-table tbody tr:nth-of-type(odd) {
    background: rgba(255, 255, 255, 0.03);
}

/* KPI Grid responsive */
@media (max-width: 576px) {
    .dashboard-panel {
        padding: 0.75rem;
        min-height: auto;
    }

    .dashboard-kpi-title {
        font-size: 0.75rem;
    }

    .dashboard-panel h2 {
        font-size: 1.75rem !important;
    }
}

.dashboard-table tbody tr:hover {
    background: rgba(0, 240, 255, 0.08);
}

/* Dashboard responsive */
@media (max-width: 1200px) {
    .dashboard-panel {
        padding: 1rem;
    }

    .dashboard-kpi-title {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .dashboard-panel {
        padding: 0.9rem;
    }

    .dashboard-kpi-title {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .dashboard-panel h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .dashboard-panel {
        padding: 0.75rem;
    }

    .dashboard-kpi-title {
        font-size: 0.7rem;
    }

    .dashboard-panel h2 {
        font-size: 1.25rem;
    }
}

/* =========================
   TABLAS AVANZADAS - RESPONSIVE
========================= */

/* Contenedor scrollable para tablas */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0,240,255,0.4);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0,240,255,0.6);
}

/* Estilos para acciones (editar, eliminar) */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    margin: 0;
}

/* Columna de acciones - ancho optimizado */
td:has(> .action-buttons) {
    width: auto;
    white-space: nowrap;
}

/* Columnas que se pueden ocultar en móviles */
@media (max-width: 992px) {
    .table-hide-lg {
        display: none;
    }
}

@media (max-width: 768px) {
    .table-hide-md {
        display: none;
    }
}

@media (max-width: 576px) {
    .table-hide-sm {
        display: none;
    }

    .table-hide-xs {
        display: none;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
        justify-content: flex-start;
    }

    .action-buttons .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        width: 100%;
        text-align: center;
    }
}

/* Estilos para filtros y controles en móviles */
.filter-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    align-items: center;
}

@media (max-width: 576px) {
    .filter-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-row input,
    .filter-row select {
        width: 100%;
    }

    .filter-row button {
        width: 100%;
    }
}

/* Títulos de página responsive */
h1, h2, h3 {
    word-wrap: break-word;
}

@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    h2 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
}

/* Contenedor con márgenes y padding responsive */
.container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Filas de datos con mejor espaciado en móviles */
.data-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.data-item {
    flex: 1;
    min-width: 150px;
}

@media (max-width: 576px) {
    .data-row {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .data-item {
        min-width: 100%;
    }
}

/* =========================
   FORMULARIOS AVANZADOS - RESPONSIVE
========================= */

/* Grupos de formularios */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: white;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: white;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #00f0ff;
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 10px rgba(0,240,255,0.3);
}

/* Formularios inline responsive */
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

@media (max-width: 768px) {
    .form-inline {
        flex-direction: column;
        gap: 1rem;
    }

    .form-inline .form-group {
        width: 100%;
        margin-bottom: 0;
    }

    .form-inline input,
    .form-inline select {
        width: 100%;
    }
}

/* Checkboxes y radios responsive */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
}

.form-check input {
    width: auto;
    margin-right: 0.75rem;
    cursor: pointer;
}

.form-check label {
    margin-bottom: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* Textarea mejorado */
textarea.form-control {
    min-height: 120px;
    resize: vertical;
    max-height: 400px;
    font-family: 'Courier New', monospace;
}

@media (max-width: 576px) {
    textarea.form-control {
        min-height: 100px;
    }
}

/* Contenedor de errores */
.form-errors {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #ff8787;
}

.form-errors ul {
    margin: 0;
    padding-left: 1.5rem;
}

/* Botones en formularios */
.form-button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

@media (max-width: 576px) {
    .form-button-group {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .form-button-group button {
        width: 100%;
    }

    .form-button-group a {
        width: 100%;
        text-align: center;
    }
}

/* Selects con mejor estilo */
select.form-control,
select.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300f0ff' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2rem;
}

/* Input tipo búsqueda mejorado */
input[type="search"],
input[type="text"].search {
    padding-left: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2300f0ff' d='M6.5 1a5.5 5.5 0 014.383 8.823l5.147 5.147a.75.75 0 01-1.06 1.06l-5.147-5.147A5.5 5.5 0 116.5 1z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
    background-size: 16px;
}

/* Validación visual mejorada */
.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: #51cf66;
}

.was-validated .form-control:valid:focus,
.form-control.is-valid:focus {
    border-color: #51cf66;
    box-shadow: 0 0 10px rgba(81, 207, 102, 0.3);
}

.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: #ff6b6b;
}

.was-validated .form-control:invalid:focus,
.form-control.is-invalid:focus {
    border-color: #ff6b6b;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
}
