/* Importar fuente Poppins de Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

:root {
    --primary-color: #2E4A4B;       /* Un verde oscuro y suave (casi teal oscuro) */
    --secondary-color: #4E7C7E;     /* Un verde-gris más claro y armonioso para gradientes */
    --background-light: #F0F4F4;    /* Fondo muy claro, con un ligero tinte verde-gris */
    --card-background: #ffffff;    /* Fondo de tarjeta blanco para contraste */
    --text-dark: #333333;           /* Texto oscuro general */
    --text-medium: #666666;         /* Texto secundario/medio */
    --border-light: #D8E0E0;        /* Borde muy claro con tinte verde-gris */
    --shadow-light: rgba(0, 0, 0, 0.08); /* Sombra más sutil */
    --hover-effect: #3F6365;        /* Un verde ligeramente más oscuro para el hover del botón */

    /* Colores para errores */
    --error-bg: #ffe0e6;
    --error-text: #cc0033;
    --error-border: #ffb3c0;

    --sidebar-width: 250px;
    --navbar-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden; /* Prevenir scroll horizontal */
}

/* --- Login Page Styles --- */
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    display: flex;
    flex-direction: column; /* Apila el card y el footer */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: auto;
}

.login-card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-light);
    padding: 40px;
    text-align: center;
    width: 100%;
}

.login-header {
    margin-bottom: 30px;
}

.logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 15px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    padding: 5px;
}

.login-header h1 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-weight: 600;
}

.login-header p {
    font-size: 1rem;
    color: var(--text-medium);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--text-medium);
    font-weight: 400;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-dark);
    background-color: var(--background-light);
    transition: all 0.3s ease;
}

.form-group input[type="text"]::placeholder,
.form-group input[type="password"]::placeholder {
    color: #a0a0a0;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-background);
    box-shadow: 0 0 0 3px rgba(46, 74, 75, 0.2);
}

.login-button {
    width: 100%;
    padding: 15px;
    background-image: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-image 0.3s ease, transform 0.2s ease;
    letter-spacing: 0.5px;
}

.login-button:hover {
    background-image: linear-gradient(to right, var(--hover-effect), var(--primary-color));
    transform: translateY(-2px);
}

.forgot-password {
    margin-top: 20px;
    font-size: 0.9rem;
}

.forgot-password a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.forgot-password a:hover {
    color: var(--hover-effect);
    text-decoration: underline;
}

/* Estilos para mensajes de error y campos con error */
.alert {
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.alert.error {
    background-color: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.form-group.has-error input {
    border-color: var(--error-text);
    background-color: var(--error-bg);
}

.help-block {
    font-size: 0.85rem;
    color: var(--error-text);
    margin-top: 5px;
    display: block;
}

/* Estilos para el footer de la página de login */
.login-footer {
    text-align: center;
    margin-top: 30px; /* Espacio entre el card de login y el footer */
    color: var(--text-medium);
    font-size: 0.85rem;
    padding: 15px 0;
}

.social-icons {
    margin-top: 15px;
    margin-bottom: 10px;
}

.social-icons a {
    display: inline-block;
    color: var(--primary-color); /* Color de los iconos */
    font-size: 1.5rem;
    margin: 0 10px;
    text-decoration: none;
    transition: color 0.3s ease, transform 0.2s ease;
}

.social-icons a:hover {
    color: var(--hover-effect); /* Color al pasar el ratón */
    transform: translateY(-2px);
}

.social-icons a.whatsapp {
    color: #25D366; /* Color específico de WhatsApp */
}
.social-icons a.whatsapp:hover {
    color: #1DA851;
}


/* --- Dashboard General Styles --- */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    padding: 20px 0;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 30px;
}

.sidebar-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 3px;
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: white;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
}

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.sidebar-nav ul li a i {
    margin-right: 15px;
    font-size: 1.1rem;
}

.sidebar-nav ul li a:hover,
.sidebar-nav ul li a.active {
    background-color: var(--secondary-color);
    color: white;
    border-left: 5px solid white;
    padding-left: 20px;
}

/* Estilos para el Dropdown en el Sidebar (submenú) */
.sidebar-dropdown {
    position: relative;
}
.sidebar-dropdown > a { /* Estilo para el elemento padre que dispara el dropdown */
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.sidebar-dropdown > a .dropdown-icon { /* Icono de flecha del dropdown */
    transition: transform 0.3s ease;
}
.sidebar-dropdown > a.active .dropdown-icon { /* Rotar flecha cuando está activo */
    transform: rotate(-180deg);
}
.dropdown-menu { /* Contenedor del submenú */
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #3d6466; /* Un poco más claro que el primary-color */
    display: none; /* Oculto por defecto */
    overflow: hidden; /* Para animaciones de slide (si se añaden JS) */
}
.dropdown-menu li a { /* Enlaces del submenú */
    padding: 10px 25px 10px 45px; /* Ajusta el padding para la sangría */
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}
.dropdown-menu li a:hover,
.dropdown-menu li a.active-submenu { /* Estilo de hover y activo para submenú */
    background-color: #4e7c7e; /* Color de hover para el submenú */
    color: white;
    border-left: none; /* No queremos borde en los submenús */
    padding-left: 45px; /* Mantener la sangría */
}


/* Main Content Area */
.main-content {
    flex-grow: 1;
    background-color: var(--background-light);
    transition: margin-left 0.3s ease;
    margin-left: 0; /* Por defecto, no hay margen extra */
    display: flex; /* Para flexbox del contenido principal y footer */
    flex-direction: column; /* Apila el main y el footer */
}

/* Navbar */
.navbar {
    background-color: var(--card-background);
    height: var(--navbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    box-shadow: 0 2px 4px var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0; /* Evita que la navbar se encoja */
}

.navbar-left {
    display: flex;
    align-items: center;
}

.navbar-left h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-left: 20px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    cursor: pointer;
    display: none; /* Ocultar por defecto en desktop, mostrar en móvil */
}

.navbar-right {
    display: flex;
    align-items: center;
}

.logged-in-user {
    font-size: 0.95rem;
    color: var(--text-medium);
    margin-right: 20px;
    display: flex;
    align-items: center;
}

.logged-in-user i {
    margin-right: 8px;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.logout-button-nav {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    background-image: linear-gradient(to right, var(--secondary-color), var(--primary-color));
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-image 0.3s ease, transform 0.2s ease;
}

.logout-button-nav i {
    margin-right: 8px;
}

.logout-button-nav:hover {
    background-image: linear-gradient(to right, var(--hover-effect), var(--primary-color));
    transform: translateY(-1px);
}

/* Dashboard Main Content Area */
.dashboard-main {
    flex-grow: 1; /* Ocupa todo el espacio restante */
    padding: 25px;
    gap: 25px;
}

.dashboard-card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    padding: 30px;
    margin-bottom: 25px;
}

.dashboard-card h3 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.dashboard-card p {
    color: var(--text-medium);
    margin-bottom: 10px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.grid-item {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    padding: 25px;
    text-align: left;
}

.grid-item h4 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.grid-item p {
    color: var(--text-medium);
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.action-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.action-link:hover {
    color: var(--primary-color);
}

.action-link i {
    margin-left: 8px;
    font-size: 0.8rem;
}

/* Estilos para el contador de licencias */
.licenses-counter {
    text-align: center;
}
.licenses-counter h4 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}
.licenses-counter .count-number {
    font-size: 3rem;
    font-weight: 600;
    color: var(--secondary-color);
    line-height: 1;
    margin-bottom: 15px;
    display: block;
}
.licenses-counter .count-text {
    font-size: 1rem;
    color: var(--text-medium);
}

/* Estilos para el footer del dashboard */
.footer {
    background-color: var(--card-background);
    color: var(--text-medium);
    text-align: center;
    padding: 15px 25px;
    font-size: 0.85rem;
    border-top: 1px solid var(--border-light);
    width: 100%;
    box-shadow: 0 -2px 4px var(--shadow-light);
    flex-shrink: 0;
}


/* --- Listado y Búsqueda de Licencias (licencias_list.php) --- */
.search-section, .list-section {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    padding: 30px;
    margin-bottom: 25px;
}
.search-section h3, .list-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8rem;
}
.search-form .form-group {
    margin-bottom: 15px;
}
.search-form label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
    display: block;
}
.search-form input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-dark);
    background-color: var(--background-light);
}
.search-actions {
    margin-top: 20px;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.search-actions button, .search-actions a.button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.search-actions button.primary, .search-actions a.button.primary {
    background-image: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}
.search-actions button.primary:hover, .search-actions a.button.primary:hover {
    background-image: linear-gradient(to right, var(--hover-effect), var(--primary-color));
    transform: translateY(-1px);
}
.search-actions button.secondary, .search-actions a.button.secondary {
    background-color: var(--background-light);
    color: var(--text-medium);
    border: 1px solid var(--border-light);
}
.search-actions button.secondary:hover, .search-actions a.button.secondary:hover {
    background-color: var(--border-light);
    color: var(--text-dark);
    transform: translateY(-1px);
}

/* Tabla de resultados */
.results-table-container {
    overflow-x: auto;
}
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9rem;
}
.results-table th, .results-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.results-table th {
    background-color: var(--background-light);
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
}
.results-table tr:hover {
    background-color: #f8fcfc;
}
.results-table .action-buttons a {
    padding: 6px 10px;
    margin-right: 5px;
    border-radius: 5px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
}
.results-table .action-buttons a.print {
    background-color: var(--primary-color);
    color: white;
}
.results-table .action-buttons a.print:hover {
    background-color: var(--hover-effect);
}
.results-table .action-buttons a.view-qr {
    background-color: var(--secondary-color);
    color: white;
}
.results-table .action-buttons a.view-qr:hover {
    background-color: #fc7d95;
}
.no-results {
    text-align: center;
    padding: 30px;
    color: var(--text-medium);
    font-size: 1.1rem;
}
.results-summary {
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-dark);
}


/* --- Administración de Usuarios (administracion_users, create, edit) --- */
.admin-form-section {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    padding: 30px;
    margin-bottom: 25px;
}
.admin-form-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8rem;
}
.admin-form-section .form-group {
    margin-bottom: 15px;
}
.admin-form-section label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
    display: block;
}
.admin-form-section input[type="text"],
.admin-form-section input[type="email"],
.admin-form-section input[type="password"],
.admin-form-section select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-dark);
    background-color: var(--background-light);
    transition: all 0.3s ease;
}
.admin-form-section input[type="text"]:focus,
.admin-form-section input[type="email"]:focus,
.admin-form-section input[type="password"]:focus,
.admin-form-section select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-background);
    box-shadow: 0 0 0 3px rgba(46, 74, 75, 0.2);
}
.admin-form-section input[readonly] {
    background-color: #e9ecef;
    cursor: not-allowed;
}
.admin-form-section .help-block {
    font-size: 0.85rem;
    color: var(--error-text);
    margin-top: 5px;
    display: block;
}
.admin-form-actions {
    margin-top: 30px;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.admin-form-actions button, .admin-form-actions a {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.admin-form-actions button.primary, .admin-form-actions a.primary {
    background-image: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
}
.admin-form-actions button.primary:hover, .admin-form-actions a.primary:hover {
    background-image: linear-gradient(to right, var(--hover-effect), var(--primary-color));
    transform: translateY(-1px);
}
.admin-form-actions a.secondary {
    background-color: var(--background-light);
    color: var(--text-medium);
    border: 1px solid var(--border-light);
}
.admin-form-actions a.secondary:hover {
    background-color: var(--border-light);
    color: var(--text-dark);
    transform: translateY(-1px);
}

/* Estilos para selección de módulos */
.module-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.module-selection label {
    display: flex;
    align-items: center;
    font-weight: normal;
    font-size: 0.95rem;
    cursor: pointer;
}
.module-selection input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

/* Tabla de usuarios */
.users-section {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    padding: 30px;
    margin-bottom: 25px;
}
.users-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8rem;
}
.user-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}
.users-table-container {
    overflow-x: auto;
}
.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9rem;
}
.users-table th, .users-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.users-table th {
    background-color: var(--background-light);
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
}
.users-table tr:hover {
    background-color: #f8fcfc;
}
.users-table .action-buttons a {
    padding: 6px 10px;
    margin-right: 5px;
    border-radius: 5px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
}
.users-table .action-buttons a.edit {
    background-color: #ffc107;
    color: white;
}
.users-table .action-buttons a.edit:hover {
    background-color: #e0a800;
}
.users-table .action-buttons a.delete {
    background-color: #dc3545;
    color: white;
}
.users-table .action-buttons a.delete:hover {
    background-color: #c82333;
}
.no-users-message {
    text-align: center;
    padding: 30px;
    color: var(--text-medium);
    font-size: 1.1rem;
}

/* Estilos para mensajes de éxito/error de administración */
.admin-alert {
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    text-align: center;
}
.admin-alert.success {
    background-color: #e6ffe6;
    color: #008000;
    border: 1px solid #b3ffb3;
}
.admin-alert.error {
    background-color: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}


/* --- Responsive General --- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1001;
        transform: translateX(-100%); /* Ocultar por defecto en móvil */
        width: var(--sidebar-width);
        transition: transform 0.3s ease; /* Asegúrate de que la transición esté aquí */
    }

    /* --- CLASE PARA MOSTRAR EL SIDEBAR EN MÓVIL --- */
    .sidebar.show {
        transform: translateX(0); /* Mostrar sidebar cuando tenga la clase 'show' */
    }

    /* El main content también se ajusta si el sidebar se superpone */
    .main-content.sidebar-shifted { /* Si quieres que el contenido se mueva a un lado (opcional) */
        margin-left: var(--sidebar-width);
    }

    .sidebar-toggle {
        display: block; /* Mostrar el botón de toggle en móvil */
        margin-right: 15px;
    }

    .navbar-left h2 {
        margin-left: 0;
    }

    .navbar-right {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .logged-in-user {
        margin-bottom: 0;
    }

    .search-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .search-actions button, .search-actions a.button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-footer {
        font-size: 0.75rem;
    }
    .social-icons a {
        font-size: 1.3rem;
        margin: 0 8px;
    }
    .dashboard-main {
        padding: 15px;
    }
    .navbar {
        padding: 0 15px;
    }
    .logged-in-user {
        display: none;
    }
    .navbar-left h2 {
        font-size: 1.2rem;
    }
    .users-section, .search-section, .list-section, .admin-form-section {
        padding: 20px;
    }
    .users-section h3, .search-section h3, .list-section h3, .admin-form-section h3 {
        font-size: 1.5rem;
    }
    /* Estilos para la organización del formulario de licencias en móvil */
    .form-grid {
        grid-template-columns: 1fr;
    }
}