.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal);
    z-index: 100;
    flex-shrink: 0;
}

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

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .credits-widget,
.sidebar.collapsed .user-name {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-primary);
    min-height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent-primary);
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.sidebar-nav {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-primary);
    color: white;
}

.nav-item.active svg {
    stroke: white;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-primary);
}

/* Credits Widget */
.credits-widget {
    padding: 0.5rem 0.25rem;
    margin-bottom: 0.5rem;
}

.credit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.credit-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.credit-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.credit-bar {
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.credit-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--transition-normal);
}

.credit-fill.ai {
    background: var(--accent-primary);
}

.credit-fill.chat {
    background: var(--accent-success);
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.user-menu-trigger:hover {
    background: var(--bg-hover);
}

.avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-name {
    flex: 1;
    text-align: left;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.user-dropdown.open {
    display: block;
}

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

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

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow: hidden;
    background: var(--bg-primary);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Alpha Banner */
.alpha-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(245, 158, 11, 0.08);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Auth Layout */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.auth-card .logo {
    justify-content: center;
    margin-bottom: 2rem;
}

.auth-card .logo-text {
    font-size: 1.5rem;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Page Layout */
.page {
    padding: 1.5rem 2rem;
    height: 100%;
    overflow-y: auto;
}

.page-fullheight {
    padding: 0;
    height: 100%;
    overflow: hidden;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--text-primary);
}

.breadcrumb .separator {
    color: var(--text-muted);
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* Notes Panel */
.notes-panel {
    position: fixed;
    right: -400px;
    top: 0;
    bottom: 0;
    width: 380px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.notes-panel.open {
    right: 0;
}

.notes-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-primary);
}

.notes-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.notes-panel-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-primary);
}

/* FAB Container */
.fab-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.75rem;
    z-index: 150;
}

/* FAB */
.fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.fab:hover {
    background: var(--accent-primary-hover);
    transform: scale(1.05);
}

.fab-assistant {
    background: var(--accent-success);
}

.fab-assistant:hover {
    background: #16a34a;
}

.fab-hidden {
    display: none;
}

/* Assistant Panel */
.assistant-panel {
    position: fixed;
    bottom: 7rem;
    right: 2rem;
    width: 380px;
    height: 450px;
    min-width: 280px;
    min-height: 200px;
    max-width: calc(100vw - 4rem);
    max-height: calc(100vh - 10rem);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}

.assistant-panel.open {
    display: flex;
}

.assistant-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.assistant-panel-header h3 {
    font-size: 0.9rem;
    margin: 0;
}

.assistant-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    min-height: 0;
}

.assistant-msg {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}

.assistant-msg.user {
    text-align: right;
}

.assistant-msg.user .assistant-msg-bubble {
    background: var(--accent-primary);
    color: white;
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-sm);
    max-width: 85%;
    text-align: left;
}

.assistant-msg.assistant .assistant-msg-bubble {
    background: var(--bg-tertiary);
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    max-width: 85%;
}

.assistant-panel-input {
    padding: 0.75rem;
    border-top: 1px solid var(--border-primary);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-shrink: 0;
}

.assistant-panel-input .form-input {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 80px;
    font-size: 0.8rem;
}

/* Task Status Bar */
.task-status-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-primary);
    padding: 0.5rem 1.5rem;
    z-index: 90;
    transition: left var(--transition-normal);
}

.task-status-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.task-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    max-width: 200px;
}

.task-progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 2px;
    transition: width var(--transition-normal);
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
