/* ============================================================================
   GARTH HMS - LAYOUT DEL SISTEMA
   Header, sidebar, main content y estructura general
   ============================================================================ */

/* ========================================
   HEADER PRINCIPAL
   ======================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    z-index: var(--z-fixed);
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background-color: var(--bg-body);
}

/* Brand */
.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

/* Theme Toggle Button */
.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--bg-body);
    color: var(--primary);
}

/* ========================================
   USER DROPDOWN
   ======================================== */
.user-dropdown {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition-fast);
}

.user-btn:hover {
    background-color: var(--bg-body);
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.user-btn span {
    font-weight: 500;
    color: var(--text-primary);
}

.user-btn i {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition-fast);
    z-index: var(--z-dropdown);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
}

.dropdown-item:hover {
    background-color: var(--bg-body);
}

.dropdown-item i {
    color: var(--text-secondary);
    width: 20px;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    z-index: calc(var(--z-fixed) - 1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar colapsado: submenú siempre oculto */
.sidebar.collapsed .submenu {
    max-height: 0 !important;
    overflow: hidden;
}

/* Separador visual entre nav items y Configuración */
.nav-separator {
    height: 1px;
    background: var(--border-color, rgba(0,0,0,0.1));
    margin: 8px 14px;
}

.sidebar.collapsed .nav-separator {
    margin: 8px 8px;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.nav-item:hover {
    background-color: rgb(0 0 0 / 20%);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-item.active {
    background-color: rgba(43, 164, 154, 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-item span {
    display: none;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
    transition: var(--transition);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-header .text-muted {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* ========================================
   DASHBOARD CONTAINER
   ======================================== */
.dashboard-container {
    max-width: 100%;
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--tertiary) 100%);
    padding: 1rem;
}

.login-box {
    background-color: var(--bg-surface);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    padding: 3rem;
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}



/* ============================================ */
/* SUBMENU EXPANDIBLE - CONFIGURACIÓN */
/* ============================================ */

/* Nav item con submenu */
.nav-item.has-submenu {
    position: relative;
    cursor: pointer;
}

/* Flecha del submenu */
.submenu-arrow {
    transition: transform 0.25s ease;
    margin-left: auto;
    font-size: 0.72rem;
    flex-shrink: 0;
}

/* Rotar flecha cuando está expandido */
.nav-item.has-submenu.expanded .submenu-arrow {
    transform: rotate(180deg);
}

/* Flecha arriba cuando el submenú está ABIERTO */
.nav-item.expanded .submenu-arrow {
    transform: rotate(180deg);
}

/* Sidebar colapsado: ocultar flecha (no se encima al ícono) */
.sidebar.collapsed .submenu-arrow {
    display: none;
}

/* Contenedor del submenu */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.04);
}

    /* Submenu expandido */
    .submenu.expanded {
        max-height: 500px; /* Ajustar según cantidad de items */
    }

/* Items del submenu */
.submenu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem 0.75rem 3rem; /* Indent a la izquierda */
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

    .submenu-item i {
        margin-right: 0.75rem;
        font-size: 0.9rem;
        width: 1.2rem;
        text-align: center;
    }

    /* Hover en submenu item */
    .submenu-item:hover {
        background: rgba(var(--primary-rgb), 0.1);
        color: var(--primary);
        border-left-color: var(--primary);
        padding-left: 3.25rem; /* Efecto de slide */
    }

    /* Submenu item activo */
    .submenu-item.active {
        background: rgba(var(--primary-rgb), 0.15);
        color: var(--primary);
        border-left-color: var(--primary);
        font-weight: 600;
    }


/* ============================================ */
/* DARK MODE - SUBMENU */
/* ============================================ */

[data-theme="dark"] .submenu {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .submenu-item:hover {
    background: rgba(var(--primary-rgb), 0.2);
}

[data-theme="dark"] .submenu-item.active {
    background: rgba(var(--primary-rgb), 0.25);
}

/* ============================================ */
/* RESPONSIVE - SUBMENU */
/* ============================================ */

@media (max-width: 768px) {
    .submenu-item {
        padding-left: 2.5rem;
        font-size: 0.85rem;
    }

        .submenu-item:hover {
            padding-left: 2.75rem;
        }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
}
