/* SIDEBAR */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 40px;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    min-width: 0;
}

.brand i {
    font-size: 22px;
    color: var(--accent-primary);
    -webkit-text-fill-color: initial;
}

.menu-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
}

.menu-item:hover {
    color: var(--text-main);
    background: var(--surface-1);
}

.menu-item.active {
    color: var(--text-main);
    background: var(--accent-glow-sm);
    border-color: rgba(139, 92, 246, 0.2);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.05);
}

.menu-item i {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.menu-item:hover i {
    transform: scale(1.1);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

/* MAIN CONTENT */
.main-content {
    flex-grow: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* APP HEADER */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    flex-shrink: 0;
}

.project-tabs-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-tab {
    padding: 8px 18px;
    border-radius: 20px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.3s ease, color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-tab:hover {
    border-color: var(--border-mid);
    color: var(--text-main);
}

.project-tab.active {
    background: var(--text-main);
    color: var(--bg-color);
    border-color: var(--text-main);
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.add-project-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px dashed var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.add-project-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: rotate(90deg);
}

.view-title-section {
    flex-shrink: 0;
}

.view-title-section h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-title-section p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* GLASS CARD */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease-out;
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* VIEW CONTAINER SWITCH */
.view-container {
    display: none;
    flex-grow: 1;
    min-height: 0;
    flex-direction: column;
}

.view-container.active {
    display: flex;
}

/* SUB-ITEMS DE PROYECTOS EN SIDEBAR */
/* Animación de colapso con grid-template-rows (sin hack de max-height) */
.sidebar-sub-items {
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    overflow: hidden;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    padding-left: 0;
}

.sidebar-sub-items.collapsed {
    grid-template-rows: 0fr;
    opacity: 0;
    pointer-events: none;
}

.sidebar-sub-items-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 8px;
    padding-left: 4px;
    min-height: 0;
}

.sidebar-project-sub-item {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    border: 1px solid transparent;
}

.sidebar-project-sub-item:hover {
    color: var(--text-main);
    background: var(--surface-1);
}

.sidebar-project-sub-item.active {
    color: var(--text-main);
    background: var(--accent-glow-sm);
    border-color: rgba(139, 92, 246, 0.2);
    font-weight: 500;
}

.sidebar-project-sub-item:hover .edit-icon-btn {
    opacity: 0.6;
}

.edit-icon-btn:hover {
    opacity: 1;
    color: var(--accent-primary);
}

.add-sidebar-project-btn {
    transition: color 0.2s ease, transform 0.2s ease;
}

.add-sidebar-project-btn:hover {
    color: var(--accent-secondary);
    transform: scale(1.2);
}

/* CLIENT GROUPS EN SIDEBAR */
.client-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.client-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.client-group-header:hover {
    background: var(--surface-1);
}

.client-group-header i.chevron {
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.client-group-header i.chevron.rotated {
    transform: rotate(180deg);
}

/* Animación de colapso de canales con grid-template-rows */
.client-channels-list {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    overflow: hidden;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
}

.client-channels-list.expanded {
    grid-template-rows: 1fr;
    opacity: 1;
}

.client-channels-list-inner {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 20px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.channel-type-badge {
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 8px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: auto;
}

#proyectos-active-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}
