.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

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

.sidebar-top {
    padding: 0.75rem;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    position: relative;
    min-height: 44px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-logo img {
    width: 40px;
    animation: float 3s infinite ease-in-out;
}

.sidebar-collapse-btn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background-color 0.2s, color 0.2s, transform 0.3s;
}

.sidebar-collapse-btn:hover {
    background-color: rgba(0,0,0,0.08);
    color: var(--text-color);
}

.sidebar.collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
    position: static;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
}

/* New analysis button */
.sidebar-new-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    text-decoration: none;
    border: 1px solid var(--outline);
    border-radius: 10px;
    background-color: var(--card-color);
    transition: background-color 0.2s, padding 0.3s ease, gap 0.3s ease,
                border-radius 0.3s ease, width 0.3s ease, height 0.3s ease,
                border-color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-new-btn svg,
.sidebar-auth-btn svg {
    flex-shrink: 0;
}

.sidebar-new-btn:hover {
    background-color: #e8e8e8;
}

.sidebar.collapsed .sidebar-new-btn:hover {
    background-color: rgba(0,0,0,0.1);
}

.sidebar.collapsed .sidebar-new-btn {
    padding: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border-color: transparent;
    background-color: rgba(0,0,0,0.06);
    margin: 0 auto;
    gap: 0;
}

/* Labels that fade when collapsed */
.sidebar-label {
    opacity: 1;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-label {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

/* History */
.sidebar-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0.5rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-history {
    opacity: 0;
    pointer-events: none;
}

.sidebar-section-title {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.25rem;
}

.sidebar-history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-history-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.sidebar-history-item:hover {
    background-color: rgba(0,0,0,0.06);
}

.sidebar-history-item.active {
    background-color: rgba(0, 122, 255, 0.1);
}

.sidebar-history-sentiment {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.dot-positive { background-color: var(--secondary-color); }
.dot-neutral { background-color: var(--neutral-color); }
.dot-negative { background-color: var(--error-color); }

.sidebar-history-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.sidebar-history-text {
    font-size: 0.8rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-history-date {
    font-size: 0.7rem;
    color: #999;
}

.sidebar-empty {
    font-size: 0.8rem;
    color: #999;
    padding: 0.5rem 0.25rem;
}

/* Bottom section (user / auth) */
.sidebar-bottom {
    padding: 0.75rem;
    border-top: 1px solid var(--outline);
    transition: padding 0.3s ease;
}

.sidebar.collapsed .sidebar-bottom {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
    gap: 0;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.7rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout-form {
    flex-shrink: 0;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-logout-form {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.2s, background-color 0.2s;
}

.sidebar-logout-btn:hover {
    color: var(--error-color);
    background-color: rgba(0,0,0,0.06);
}

/* Auth buttons inside sidebar */
.sidebar-auth {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.55rem;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s, padding 0.3s ease,
                border-radius 0.3s ease, width 0.3s ease, height 0.3s ease,
                border-color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-auth-login {
    color: var(--primary-color);
    background-color: transparent;
    border: 1px solid var(--primary-color);
}

.sidebar-auth-login:hover {
    background-color: rgba(0, 122, 255, 0.08);
}

.sidebar-auth-register {
    color: white;
    background-color: var(--primary-color);
}

.sidebar-auth-register:hover {
    background-color: #005ecb;
}

.sidebar.collapsed .sidebar-auth-btn {
    padding: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin: 0 auto;
    gap: 0;
}

.sidebar.collapsed .sidebar-auth-login {
    border-color: transparent;
    background-color: rgba(0, 122, 255, 0.1);
}

.sidebar.collapsed .sidebar-auth-register {
    border: none;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.3);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
