/* layout.css - 布局、侧边栏、模式选择器、会话输入、状态、侧边栏按钮 */

/* ===== Layout ===== */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ===== Sidebar Toggle ===== */
.sidebar-toggle {
    position: fixed;
    left: var(--sidebar-width);
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    width: 24px;
    height: 48px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-sketch);
    border-left: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sketch);
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    box-shadow: 3px 4px 0px rgba(60, 50, 30, 0.15);
}

.sidebar-toggle svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

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

.sidebar-toggle.collapsed {
    left: 0;
}

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

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 2px solid var(--border-sketch);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
}

.sidebar::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background: repeating-linear-gradient(to bottom, transparent, transparent 4px, var(--border-sketch) 4px, var(--border-sketch) 8px);
    opacity: 0.3;
}

.sidebar.collapsed {
    width: 0;
    opacity: 0;
    border-right: none;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 2px dashed var(--border-color);
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-top-actions,
.sidebar.collapsed .sidebar-sessions,
.sidebar.collapsed .sidebar-footer {
    opacity: 0;
    pointer-events: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    object-fit: contain;
    filter: drop-shadow(1px 2px 0px rgba(31, 29, 26, 0.16));
}

.logo-text {
    font-family: var(--font-hand);
    font-size: 22px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 1px;
}

/* New Session Button */
.sidebar-top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 8px 12px;
    flex-shrink: 0;
}

.sidebar-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 6px;
    background: transparent;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-hand);
    color: var(--text-secondary);
    transition: all var(--transition);
    position: relative;
}

.sidebar-action-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.sidebar-action-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-action-btn.new-session-btn {
    grid-column: 1 / -1;
    background: var(--accent-light);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: 500;
    padding: 8px 10px;
    font-size: 13px;
    border-width: 2px;
}

.sidebar-action-btn.new-session-btn:hover {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sketch);
    transform: translateY(-1px);
}

.sidebar-action-btn.history-manage-btn:hover {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--info);
    box-shadow: var(--shadow-sketch);
    transform: translateY(-1px);
}

.sidebar-action-btn.schedule-manage-btn:hover {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
    box-shadow: var(--shadow-sketch);
    transform: translateY(-1px);
}

.sidebar-action-btn.fm-open-btn:hover {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
    box-shadow: var(--shadow-sketch);
    transform: translateY(-1px);
}

.sidebar-action-btn.config-open-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sketch);
    transform: translateY(-1px);
}

/* Sidebar Sessions */
.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    transition: opacity 0.2s ease;
    min-height: 0;
}

.sidebar-session-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-session-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--text-tertiary);
    font-family: var(--font-hand);
    font-size: 16px;
}

.sidebar-session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    min-height: 40px;
}

.sidebar-session-item.menu-open {
    z-index: 20;
}

.sidebar-session-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.sidebar-session-item.active {
    background: var(--accent-light);
    border-color: var(--accent-primary);
    box-shadow: 0 1px 0 rgba(60, 50, 30, 0.08);
}

.sidebar-session-item .session-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.sidebar-session-item.active .session-icon {
    color: var(--accent-primary);
}

.sidebar-session-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding-right: 34px;
}

.sidebar-session-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    line-height: 1.4;
}

.sidebar-session-time {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

.sidebar-session-actions {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 3;
}

.sidebar-session-item:hover .sidebar-session-actions,
.sidebar-session-item.active .sidebar-session-actions,
.sidebar-session-item.menu-open .sidebar-session-actions {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-session-menu-trigger {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition);
    padding: 0;
}

.sidebar-session-menu-trigger:hover,
.sidebar-session-item.menu-open .sidebar-session-menu-trigger {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-session-menu-trigger svg {
    width: 15px;
    height: 15px;
}

.sidebar-session-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    min-width: 112px;
    display: none;
    padding: 5px;
    border: 1.5px solid var(--border-color);
    border-radius: 9px;
    background: var(--bg-secondary);
    box-shadow: 2px 4px 0 rgba(60, 50, 30, 0.12);
    z-index: 4;
}

.sidebar-session-item.menu-open .sidebar-session-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-session-menu-item {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 7px 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    transition: all var(--transition);
}

.sidebar-session-menu-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-session-menu-item.delete-action:hover {
    color: var(--error);
    background: var(--error-light);
}

.sidebar-session-menu-item svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* 会话状态标签 */
.session-status-label {
    font-size: 10px;
    font-weight: 500;
}

.session-status-label.processing {
    color: var(--primary);
    animation: session-pulse 1.5s ease-in-out infinite;
}

.session-status-label.completed {
    color: var(--success);
}

@keyframes session-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 2px dashed var(--border-color);
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

/* Mode Selector */
.mode-selector {
    margin-bottom: 8px;
}

.mode-label {
    display: block;
    font-family: var(--font-hand);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition);
    white-space: nowrap;
}

.mode-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.mode-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sketch);
}

.mode-btn.active {
    background: var(--accent-light);
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sketch);
    font-weight: 500;
}

.mode-btn.deep-mode-btn.active {
    background: linear-gradient(135deg, #eef0f9, #e8eaf6);
    box-shadow: 2px 3px 0px rgba(107, 127, 198, 0.2);
}

/* Status */
.status-section {
    margin-bottom: 8px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 2px dashed var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

.version-tag {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-tertiary);
    opacity: 0.7;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: default;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 6px rgba(125, 184, 127, 0.4);
}

.status-dot.disconnected {
    background: var(--text-tertiary);
}

.status-dot.processing {
    background: var(--warning);
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 6px rgba(212, 165, 74, 0.4);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Sidebar Actions Row - removed, moved to sidebar-top-actions */

/* ===== Custom Sketch Tooltip (JS-based, appended to body) ===== */
.sketch-tooltip {
    position: fixed;
    z-index: 99999;
    padding: 6px 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-sketch);
    border-radius: 8px;
    font-family: var(--font-hand);
    font-size: 13px;
    white-space: nowrap;
    box-shadow: 2px 3px 0px rgba(60, 50, 30, 0.1);
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sketch-tooltip.visible {
    opacity: 1;
}

.sketch-tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}

.sketch-tooltip-arrow.arrow-left {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: var(--border-sketch);
}

.sketch-tooltip-arrow.arrow-top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: var(--border-sketch);
}

.sketch-tooltip-arrow.arrow-bottom {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: var(--border-sketch);
}

.sketch-tooltip-arrow.arrow-right {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: var(--border-sketch);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {

    /* 聊天容器移动端内边距 */
    .chat-container {
        padding: 0 12px;
    }

    /* 会话项更紧凑 */
    .sidebar-session-item {
        padding: 10px 12px;
    }

    .sidebar-session-info {
        padding-right: 44px;
    }

    .sidebar-session-name {
        font-size: 13px;
    }

    .sidebar-session-time {
        font-size: 10px;
    }

    /* 模式选择器紧凑 */
    .mode-buttons {
        gap: 3px;
    }

    .mode-btn {
        padding: 5px 6px;
        font-size: 11px;
    }

    .mode-btn svg {
        width: 12px;
        height: 12px;
    }

    /* 侧边栏按钮紧凑 */
    .sidebar-top-actions {
        gap: 4px;
        padding: 6px 10px;
    }

    .sidebar-action-btn {
        padding: 6px 4px;
        font-size: 11px;
    }

    .sidebar-action-btn svg {
        width: 14px;
        height: 14px;
    }

    .sidebar-action-btn.new-session-btn {
        padding: 7px 8px;
        font-size: 12px;
    }
}
