/* Sidebar */
.sidebar {
    background: var(--sidebar-bg);
    color: white;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1000;
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--shadow-strong);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
}

.sidebar-header h5 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #FFFFFF 0%, #E6EDFF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.01em;
}

.sidebar-header small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Mobile Sidebar Close Button */
.sidebar-close-btn {
    display: none; /* Hidden on desktop */
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    color: white;
    z-index: 10;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(107, 126, 232, 0.2);
}

.sidebar-close-btn:active {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.95);
}

/* Custom CSS X icon (two crossed lines) */
.close-icon-custom {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-line {
    position: absolute;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

.close-line-1 {
    transform: rotate(45deg);
}

.close-line-2 {
    transform: rotate(-45deg);
}

.sidebar-close-btn:hover .close-line {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

/* Show close button on mobile */
@media (max-width: 768px) {
    .sidebar-close-btn {
        display: flex;
    }

    /* Ensure sidebar-header has relative positioning for absolute button */
    .sidebar-header {
        position: relative;
    }
}

.sidebar-button {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-radius: 16px;
    margin: 8px 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    text-decoration: none;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 1.0625rem;
    box-shadow: var(--shadow-soft);
    letter-spacing: 0.005em;
}

.sidebar-button:hover {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 8px 32px rgba(107, 126, 232, 0.3), 
                0 0 20px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
}

.sidebar-button i {
    margin-right: 10px;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.conversation-item {
    padding: 6px 14px;
    border-radius: 12px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
    font-size: 0.9rem;
    border: 1px solid transparent;
    letter-spacing: 0.005em;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.conversation-item:active {
    font-weight: 700;
}

.conversation-item.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.95) 100%);
    color: #1A1B3A;
    font-weight: 700;
    border: 1px solid rgba(107, 126, 232, 0.4);
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Conversation Group Styles */
.conversation-group {
    margin-bottom: 16px;
}

.conversation-group-header {
    padding: 8px 16px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid rgba(107, 126, 232, 0.5);
    border-radius: 0 4px 4px 0;
    font-family: 'Outfit', sans-serif;
    transition: all 0.2s ease;
}

.conversation-group-header:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
    border-left-color: rgba(107, 126, 232, 0.7);
}

/* Adjust conversation items within groups */
.conversation-group .conversation-item:first-of-type {
    margin-top: 2px;
}

.conversation-group .conversation-item:last-of-type {
    margin-bottom: 2px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
}

.about-rasto-link {
    color: white;
    text-decoration: underline;
    font-size: 0.9rem;
    opacity: 0.9;
    transition: all 0.3s;
    cursor: pointer;
}

.about-rasto-link:hover {
    opacity: 1;
}

/* Guild Section */
.sidebar .guild-section {
    margin: 16px 16px;
    padding: 16px;
    background: rgba(184, 134, 11, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(184, 134, 11, 0.3);
    backdrop-filter: blur(10px);
}

.guild-section-divider {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.guild-section-divider::before,
.guild-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(184, 134, 11, 0.5), transparent);
}

.guild-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #D4AF37;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* Guild menu buttons - used for all buttons in the GUILD section */
.guild-menu-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--guild-gold) 0%, var(--guild-gold-dark) 100%);
    color: white;
    font-family: "Outfit", sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 24px rgba(184, 134, 11, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.guild-menu-button:hover,
.guild-menu-button:focus {
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.95) 0%, rgba(150, 115, 33, 0.95) 100%);
    box-shadow: 0 8px 24px rgba(184, 134, 11, 0.35);
    color: white;
    text-decoration: none;
}

.guild-menu-button:active {
    background: linear-gradient(135deg, rgba(150, 115, 33, 0.95) 0%, rgba(120, 90, 20, 0.95) 100%);
    box-shadow: 0 8px 20px rgba(184, 134, 11, 0.3);
}

.guild-menu-button:focus-visible {
    outline: 3px solid rgba(184, 134, 11, 0.45);
    outline-offset: 3px;
}

.guild-menu-button__text {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .guild-menu-button {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
}

.sidebar .guild-section .guild-menu-button,
.sidebar .guild-section .guild-menu-button:link,
.sidebar .guild-section .guild-menu-button:visited {
    margin-bottom: 8px;
    display: block;
    text-align: center;
    padding: 8px 16px !important; /* More compact - override default 12px 20px */
    font-size: 0.9rem !important; /* Slightly smaller text */
}

.sidebar .guild-section .guild-menu-button:last-child {
    margin-bottom: 0;
}

/* Ensure sidebar footer stays at bottom and only contains user info */
.sidebar-footer {
    margin-top: auto; /* Push to bottom */
}

/* Sidebar Auth Message */
.sidebar-auth-message {
    margin: 16px 16px 8px 16px;
    text-align: center;
}

.sidebar-auth-divider {
    height: 1px;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    margin: 12px 0;
}

.sidebar-auth-quote {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    opacity: 0.9;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 100vh;
        position: fixed;
        left: -100%;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1050; /* Above mobile header (1040) and guild banner (1045) when shown */
    }

    .sidebar.show {
        left: 0;
    }

    /* Reduce sidebar-header padding (top/bottom only) */
    .sidebar-header {
        padding: 12px 20px;
    }

    /* Add spacing to About Rasto link */
    .about-rasto-link {
        display: block;
        margin-top: 0.5rem;
    }

    /* Reduce sidebar-footer padding (top/bottom only) */
    .sidebar-footer {
        padding: 5px 20px;
    }

    /* Reduce New Chat button wrapper margin */
    .mt-3.px-3 {
        margin-top: 0.5rem !important;
    }

    /* Hide GUILD caption on mobile */
    .guild-section-label {
        display: none;
    }

    /* Hide guild section divider on mobile */
    .guild-section-divider {
        display: none;
    }

    /* Reduce guild-section padding and margin (top/bottom only) */
    .sidebar .guild-section {
        margin: 5px 16px;
        padding: 5px 16px;
    }

    /* Make guild menu buttons more compact (reduce top/bottom padding) */
    .sidebar .guild-section .guild-menu-button {
        padding: 6px 16px !important;
    }

    /* Conversation list - reduce padding and no top margin */
    .conversation-list {
        margin-top: 0;
        padding: 5px 16px;
    }
}
