* {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    font-size: 13px;
    background-color: #f3f3f3;
    margin: 0;
    padding: 0;
    color: #333;
}

a { text-decoration: none; color: #235a81; }
a:hover { text-decoration: underline; color: #235a81; }

/* Layout para el Dashboard */
.container-flex {
    display: flex;
    height: 100vh;
    position: relative; /* Necesario para el sidebar absoluto en móvil */
}

.sidebar {
    width: fit-content;
    min-width: 200px;
    background: #f3f3f3;
    border-right: 1px solid #999;
    padding: 10px;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 1000; /* Asegurar que quede por encima en móvil */
    white-space: nowrap;
    overflow-x: hidden; /* Ocultar contenido horizontal al colapsar */
}

.sidebar.collapsed {
    width: 55px;
    min-width: 55px;
    padding: 10px 5px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .logo,
.sidebar.collapsed .footer-info {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
}

.sidebar.collapsed .nav-item i {
    margin-right: 0 !important;
}

.main-content {
    flex: 1;
    padding: 15px;
    background: #fff;
    overflow-y: auto;
}

.main-content > h2 {
    margin-top: 0;
    border-bottom: 1px solid #acacac;
    padding-bottom: 5px;
    font-size: 1.1em;
    background: #eaeaea;
    margin: -15px -15px 15px -15px;
    padding: 8px 15px;
    color: #555;
    font-weight: bold;
}

.logo {
    font-weight: bold;
    font-size: 1.3em;
    margin-bottom: 15px;
    display: block;
    color: #f79646; /* Naranja tipo PMA */
    text-shadow: 1px 1px 0 #fff;
    padding-left: 5px;
}

.nav-item {
    display: block;
    padding: 5px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

.nav-item:hover {
    background-color: #e8e8e8;
    color: #000;
}

/* Estilos para Login/Registro (Cajas centradas) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background: #f3f3f3;
    padding: 15px;
    padding-top: 25vh;
}

.card {
    border: 1px solid #acacac;
    background: #f9f9f9;
    padding: 15px;
    width: 100%;
    max-width: 350px;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.card h2 {
    margin-top: 0;
    border-bottom: 1px solid #acacac;
    padding-bottom: 5px;
    font-size: 1.1em;
    background: #eaeaea;
    margin: -15px -15px 15px -15px;
    padding: 8px 15px;
    color: #555;
    font-weight: bold;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: bold;
    font-size: 0.9em;
}

.form-control {
    width: 100%;
    padding: 4px;
    border: 1px solid #aaa;
    font-size: 1em;
}

.btn {
    background: #efefef;
    border: 1px solid #999;
    padding: 4px 10px;
    cursor: pointer;
    font-weight: bold;
    color: #000;
    border-radius: 2px;
    font-size: 0.9em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn:hover {
    background: #e0e0e0;
    border-color: #666;
}

.alert {
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    font-size: 0.9em;
}
.alert-danger { background: #ffcccc; border-color: #ff9999; color: #990000; }
.alert-success { background: #ccffcc; border-color: #99ff99; color: #006600; }

.no-padding { padding: 0 !important; }

.top-bar {
    background: #eaeaea;
    padding: 5px 10px;
    border-bottom: 1px solid #aaa;
    margin: -15px -15px 0 -15px; /* Quitar margen inferior para pegar el menú */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Overlay para móvil (Fondo oscuro) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Estilos para Móvil */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1050;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        transform: translateX(0);
    }
    
    /* En móvil, 'collapsed' significa moverlo fuera de la pantalla, no ancho 0 */
    .sidebar.collapsed {
        width: fit-content;
        min-width: 200px;
        padding: 10px; /* Mantener padding original */
        border-right: 1px solid #999;
        transform: translateX(-100%);
    }
    
    .card { width: 100%; margin: 0 auto; max-width: 100%; }
    .top-bar { flex-wrap: wrap; gap: 10px; }

    .auth-container {
        align-items: flex-start;
        padding-top: 10vh; /* Empuja la caja un 10% hacia abajo desde el tope */
    }

    .form-control, .btn {
        font-size: 16px; /* Evita zoom en iOS y mejora tacto */
        padding: 8px;
    }

    .domain-link {
        display: none;
    }
}

/* Password Toggle (Ojo) */
.password-group {
    position: relative;
}

.password-group input {
    padding-right: 40px; /* Espacio para el icono */
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
    line-height: 1;
    color: #777;
}

/* Menú Secundario (Tabs tipo phpMyAdmin) */
.secondary-nav {
    background: #e0e0e0;
    padding: 0;
    border-bottom: none;
    margin: 0 -15px 15px -15px;
    display: flex;
    overflow-x: auto; /* Scroll horizontal en móvil */
    overflow-y: hidden;
    align-items: flex-end;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.secondary-nav::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.nav-tab {
    display: flex;
    align-items: center;
    padding: 5px 10px 5px 10px;
    text-decoration: none;
    color: #333;
    background: #e0e0e0;
    border: none;
    border-right: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    border-radius: 0;
    margin-right: 0;
    font-size: 0.95em;
    white-space: nowrap;
    height: 100%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.nav-tab:last-child {
    border-right: none;
}

.nav-tab:hover {
    background: #f9f9f9;
    color: #000;
}

.nav-tab.active {
    background: #fff;
    font-weight: bold;
    margin-bottom: 0;
    border-bottom: 1px solid #fff;
}

.nav-tab i {
    margin-right: 5px;
    font-size: 1.1em;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 3% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.modal .card {
    margin-top: 5% !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: bold;
    color: #555;
}

.close {
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
}

.modal-tabs .modal-tab-link {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: bold;
    color: #555;
    transition: 0.3s;
}

.modal-tabs .modal-tab-link:hover {
    background-color: #f9f9f9;
}

.modal-tabs .modal-tab-link.active {
    border-bottom: 2px solid #235a81;
    color: #235a81;
}

.modal-tab-content {
    display: none;
    animation: fadeEffect 0.3s;
}

@keyframes fadeEffect {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mejoras para tablas en móvil */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }
    .table-compact th, .table-compact td {
        padding: 6px 4px !important;
    }
}

/* Ajuste específico para pestañas activas en modales */
.modal .nav-tab.active {
    border-bottom: none;
}