/* ============================================
    GRAPHEINCR - SIDEBAR & LOGIN STYLES
    Navegación vertical y autenticación
   ============================================ */

:root {
    --sidebar-width: 280px;
    --sidebar-width-collapsed: 80px;
    --transition-sidebar: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SIDEBAR VERTICAL
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(135deg, var(--glass-bg-dark) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    overflow: visible; /* Permitir que los dropdowns salgan */
    transition: width var(--transition-sidebar), left var(--transition-sidebar);
    padding-top: 0;
    display: flex; /* Flexbox para empujar el footer abajo */
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

/* ---- MAIN CONTENT CON SIDEBAR ---- */
body.with-sidebar {
    padding-left: var(--sidebar-width);
}

body.with-sidebar.sidebar-collapsed {
    padding-left: var(--sidebar-width-collapsed);
}

#header-grapheincr {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 998;
    transition: left var(--transition-sidebar);
}

body.sidebar-collapsed #header-grapheincr {
    left: var(--sidebar-width-collapsed);
}

main {
    margin-top: 80px;
}

/* ---- SIDEBAR HEADER ---- */
.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0; /* Evita que el header se encoja */
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    font-weight: var(--font-weight-extra-bold);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.sidebar-brand i {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-brand span {
    display: none;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(79, 70, 229, 0.1);
    transform: rotate(10deg);
    transform: scale(1.1);
}

/* Rotar la flecha cuando el sidebar está colapsado */
.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-toggle:hover {
    transform: rotate(180deg) scale(1.1);
}

/* ---- SIDEBAR MENU ---- */
.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex: 1; /* Ocupa todo el espacio disponible */
    overflow-y: auto; /* Scroll solo en el menú */
    overflow-x: hidden;
}

.sidebar-nav-section {
    margin: 1rem 0;
}

.sidebar-nav-section-title {
    color: var(--color-text);
    font-size: 0.75rem;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.75rem 1rem;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-nav-section-title {
    display: none;
}

.nav-item-sidebar {
    margin: 0.25rem 0.5rem;
}

.nav-link-sidebar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    border-radius: 10px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    font-size: 0.9rem;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
}

.nav-link-sidebar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    transform: translateX(-4px);
    transition: transform var(--transition-normal);
}

.nav-link-sidebar:hover {
    background: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
    transform: translateX(4px);
}

.nav-link-sidebar:hover::before {
    transform: translateX(0);
}

.nav-link-sidebar.active {
    background: rgba(79, 70, 229, 0.12);
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

.nav-link-sidebar.active::before {
    transform: translateX(0);
}

.nav-icon-sidebar {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}

.nav-text-sidebar {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .nav-text-sidebar {
    display: none;
}

/* ---- SUBMENU ---- */
.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
}

.nav-item-sidebar.expanded .nav-submenu {
    max-height: 500px;
}

.nav-item-submenu {
    margin: 0;
}

.nav-link-submenu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem 0.6rem 3rem;
    color: var(--color-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-normal);
    font-size: 0.85rem;
    white-space: nowrap;
}

.nav-link-submenu:hover {
    background: rgba(79, 70, 229, 0.08);
    color: var(--color-primary);
    padding-left: 3.25rem;
}

.nav-link-submenu.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
}

.dropdown-icon {
    margin-left: auto;
    transition: transform var(--transition-normal);
    font-size: 0.75rem;
}

.nav-item-sidebar.expanded .dropdown-icon {
    transform: rotate(180deg);
}

/* ---- SIDEBAR FOOTER ---- */
.sidebar-footer {
    position: relative;
    margin-top: auto; /* Empuja el footer al final */
    flex-shrink: 0; /* Evita que se encoja */
    padding: 1rem 0.5rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.5);
    z-index: 1050;
}

/* Dropdown del usuario en sidebar */
.sidebar-footer .dropup {
    position: relative;
}

.sidebar-footer .dropdown-menu {
    position: absolute !important;
    display: none;
    z-index: 1060;
    min-width: 220px;
    width: calc(100% - 1rem);
    border-radius: 10px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.5rem 0;
    bottom: 100% !important;
    top: auto !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    transform: none !important;
    margin-bottom: 8px;
    background: #fff;
    inset: auto !important;
}

.sidebar-footer .dropdown-menu.show {
    display: block !important;
    bottom: 100% !important;
    left: 0.5rem !important;
    position: absolute !important;
}

.sidebar-footer .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
    margin: 0 0.25rem;
}

.sidebar-footer .dropdown-item:hover {
    background: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
}

.sidebar-footer .dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0;
    cursor: pointer;
    border-radius: 10px;
    transition: all var(--transition-normal);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

.sidebar-user:hover {
    background: rgba(79, 70, 229, 0.1);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--color-text);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-user-info {
    display: none;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

/* Estilos específicos para el cuerpo de Login */
.login-page {
    overflow-x: hidden;
    overflow-y: auto;
}

/* Estilos específicos para el cuerpo de Registro */
.signup-page {
    overflow-y: auto; /* Permite scroll en registro ya que el formulario es largo */
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-card {
    background: var(--glass-bg-dark);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 3rem 2rem;
    animation: slideUp 0.6s ease;
}

.login-page .login-card {
    padding-top: 4rem;
    padding-bottom: 4rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: 16px;
    margin-bottom: 1rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.login-logo i {
    color: var(--color-white);
    font-size: 2rem;
}

.login-title {
    font-size: 1.75rem;
    font-weight: var(--font-weight-extra-bold);
    color: var(--color-dark);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--color-text);
    opacity: 0.8;
}

/* ---- FORM INPUTS ---- */
.form-group-login {
    margin-bottom: 1.5rem;
}

.form-label-login {
    display: block;
    color: var(--color-dark);
    font-weight: var(--font-weight-medium);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.form-control-login {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--color-dark);
    transition: all var(--transition-normal);
    font-family: var(--font-sans);
}

.form-control-login:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control-login::placeholder {
    color: var(--color-text);
    opacity: 0.6;
}

/* ---- CHECKBOX REMEMBER ---- */
.remember-forgot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.form-check-login {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-check-login input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.form-check-label-login {
    color: var(--color-text);
    cursor: pointer;
    margin-bottom: 0;
}

.forgot-password {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-normal);
}

.forgot-password:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}

/* ---- LOGIN BUTTON ---- */
.btn-login {
    width: 100%;
    padding: 0.95rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: var(--color-white);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
    margin-bottom: 1rem;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(79, 70, 229, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ---- SIGNUP LINK ---- */
.signup-link {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text);
}

.signup-link a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: var(--font-weight-bold);
    transition: all var(--transition-normal);
}

.signup-link a:hover {
    color: var(--color-secondary);
}

/* ---- DIVIDER ---- */
.divider-login {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--color-text);
    font-size: 0.85rem;
    opacity: 0.6;
}

.divider-login::before,
.divider-login::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* ---- SOCIAL LOGIN ---- */
.social-login {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: var(--color-dark);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-social i {
    font-size: 1.1rem;
}

.google-icon {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
}

.btn-social:hover {
    background: rgba(255, 255, 255, 0.7);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ---- ERROR MESSAGE ---- */
.alert-login {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.alert-login.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.alert-login.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #059669;
}

/* ---- LOGIN FOOTER INFO ---- */
/* Información al pie del formulario (Credenciales, etc.) */
.login-footer-info {
    text-align: center;
    margin-top: 4rem; /* Aumentado el margen superior para dar más espacio */
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.login-footer-info p {
    margin-bottom: 0.5rem;
}

.login-footer-info p:last-child {
    margin-bottom: 0;
}

/* ============================================
   RESPONSIVE SIDEBAR
   ============================================ */

@media (max-width: 767.98px) {
    .sidebar {
        left: -100%;
        width: var(--sidebar-width);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    }

    /* On mobile, always render full-width sidebar even if desktop collapsed state was saved */
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

    .sidebar.show {
        left: 0;
    }

    body.with-sidebar {
        padding-left: 0;
    }

    #header-grapheincr {
        left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        display: none;
    }

    .sidebar.show ~ .sidebar-overlay {
        display: block;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }

    main {
        margin-top: 80px;
    }
}

@media (max-width: 575.98px) {
    .login-card {
        padding: 2rem 1.5rem;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .social-login {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MEJORAS DE UX: EXPANDIR AL HOVER
   ============================================ */

@media (min-width: 768px) {
    /* Cuando el sidebar está colapsado y pasas el mouse, se expande temporalmente */
    .sidebar.collapsed:hover {
        width: var(--sidebar-width);
    }

    /* Mostrar textos y elementos ocultos al hacer hover */
    .sidebar.collapsed:hover .nav-text-sidebar,
    .sidebar.collapsed:hover .sidebar-nav-section-title,
    .sidebar.collapsed:hover .sidebar-user-info {
        display: block;
    }

    .sidebar.collapsed:hover .sidebar-brand span {
        display: inline;
    }
}

/* ============================================
   DARK MODE GLOBAL OVERRIDES
   ============================================ */

body.dark-theme,
body.dark-theme.with-sidebar {
    background: #0b0f14;
    color: #e5e7eb;
}

body.dark-theme main,
body.dark-theme .container,
body.dark-theme .container-fluid {
    background: transparent;
    color: #e5e7eb;
}

body.dark-theme .sidebar {
    background: linear-gradient(135deg, rgba(16, 22, 30, 0.96) 0%, rgba(10, 14, 20, 0.96) 100%);
    border-right-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .sidebar-footer {
    background: rgba(8, 12, 18, 0.8);
    border-top-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .sidebar-nav-section-title,
body.dark-theme .sidebar-user-name,
body.dark-theme .form-label,
body.dark-theme .text-dark {
    color: #f3f4f6 !important;
}

body.dark-theme .nav-link-sidebar,
body.dark-theme .nav-link-submenu,
body.dark-theme .sidebar-user,
body.dark-theme .sidebar-user-role,
body.dark-theme .text-muted {
    color: #cbd5e1 !important;
}

body.dark-theme .nav-link-sidebar:hover,
body.dark-theme .nav-link-submenu:hover,
body.dark-theme .sidebar-user:hover {
    background: rgba(79, 70, 229, 0.2);
    color: #ffffff !important;
}

body.dark-theme .card,
body.dark-theme .card-modern,
body.dark-theme .modal-content,
body.dark-theme .dropdown-menu,
body.dark-theme .list-group-item,
body.dark-theme .table,
body.dark-theme .table > :not(caption) > * > * {
    background-color: #111827 !important;
    color: #e5e7eb !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

body.dark-theme .table-light,
body.dark-theme .table-light th,
body.dark-theme .table-light td {
    background-color: #1f2937 !important;
    color: #f3f4f6 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-theme .form-control,
body.dark-theme .form-select,
body.dark-theme .form-control-login,
body.dark-theme .input-group-text,
body.dark-theme textarea,
body.dark-theme input {
    background-color: #0f172a !important;
    color: #e5e7eb !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

body.dark-theme .form-control::placeholder,
body.dark-theme .form-control-login::placeholder,
body.dark-theme .form-select::placeholder,
body.dark-theme textarea::placeholder,
body.dark-theme input::placeholder {
    color: #94a3b8 !important;
}

body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus,
body.dark-theme .form-control-login:focus,
body.dark-theme textarea:focus,
body.dark-theme input:focus {
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.3) !important;
    border-color: rgba(129, 140, 248, 0.9) !important;
}

body.dark-theme .bg-light,
body.dark-theme .bg-white {
    background-color: #1f2937 !important;
    color: #e5e7eb !important;
}

body.dark-theme .alert-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.4);
}

body.dark-theme .alert-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
}

body.dark-theme .alert-success {
    background: rgba(16, 185, 129, 0.2);
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.4);
}
