/**
 * Floating Chat - Left Side Panel Style
 */

/* Backdrop Overlay */
.chat-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.chat-panel-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* Floating Button Container */
.floating-chat-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 620;
}

/* Wide Floating Button */
.floating-chat-btn {
    height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), var(--glow-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.floating-chat-btn .btn-text {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.floating-chat-btn i {
    font-size: 16px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-chat-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25), var(--glow-primary);
}

.floating-chat-btn.active i {
    transform: rotate(180deg) scale(1.2);
}

.floating-chat-btn.active {
    background: var(--bg-elevated);
    color: var(--accent-primary);
    border: 1px solid var(--border-highlight);
}

/* Side Panel */
.floating-chat-menu {
    position: fixed;
    top: 0;
    left: -420px;
    width: 420px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-primary);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    z-index: 610;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
}

.floating-chat-menu.show {
    left: 0;
    visibility: visible;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.3);
}

/* Header */
.floating-chat-header {
    padding: 20px 20px 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.floating-chat-header h6 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
}

/* List Area */
.floating-chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 80px 12px;
}

/* Grouping */
.chat-group-section {
    margin-bottom: 16px;
}

.chat-group-header {
    padding: 4px 8px 6px 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* Row List */
.chat-row-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-row {
    display: flex;
    align-items: center;
    border-radius: 0;
    transition: background var(--transition-base);
    border-bottom: 1px solid var(--border-primary);
}

.chat-row:first-child {
    border-top: 1px solid var(--border-primary);
}

.chat-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.chat-row:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

.chat-row-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    text-decoration: none;
    min-width: 0;
}

.chat-row-icon {
    width: 28px;
    height: 28px;
    background: var(--bg-elevated);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-tertiary);
    border: 1px solid var(--border-primary);
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.chat-row:hover .chat-row-icon {
    background: var(--accent-primary);
    color: #fff;
    border-color: transparent;
}

.chat-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.chat-row-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-row-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    white-space: nowrap;
}

/* 즐겨찾기 버튼 */
.chat-row-favorite {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    opacity: 1;
    transition: color 0.15s, background 0.15s;
}

.chat-row-favorite:hover {
    background: var(--bg-elevated);
    color: var(--accent-primary);
}

.chat-row-favorite i.chat-row-favorite--active {
    color: var(--accent-primary);
}

.chat-row-favorite:has(i.chat-row-favorite--active) {
    opacity: 1;
    color: var(--accent-primary);
}

/* 제목 수정 버튼 */
.chat-row-rename {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    opacity: 1;
    transition: color 0.15s, background 0.15s;
}

.chat-row-rename:hover {
    background: var(--bg-elevated);
    color: var(--accent-primary);
}

/* 인라인 제목 편집 */
.chat-row-title-input {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--accent-primary);
    border-radius: 5px;
    padding: 2px 6px;
    outline: none;
    min-width: 0;
}

/* 삭제 버튼 */
.chat-row-delete {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-right: 4px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    opacity: 1;
    transition: color 0.15s, background 0.15s;
}

.chat-row-delete:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Footer Controls */
.floating-chat-footer {
    padding: 14px 16px 72px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.btn-chrome {
    width: 100%;
    height: 40px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    text-align: center;
}

.empty-state-icon {
    width: 60px;
    height: 60px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
    border: 1px solid var(--border-primary);
}

.empty-state-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

/* Scrollbar */
.floating-chat-list::-webkit-scrollbar {
    width: 3px;
}
.floating-chat-list::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 10px;
}

/* ── 태블릿 (641px ~ 900px): 패널 너비 축소 ── */
@media (max-width: 900px) and (min-width: 481px) {
    .floating-chat-menu {
        left: -85vw;
        width: 85vw;
    }

    .floating-chat-menu.show {
        left: 0;
    }
}

/* ── 모바일 반응형 (≤640px) ── */
@media (max-width: 640px) {
    /* 채팅 페이지에서 입력창과 겹치지 않도록 버튼 위치 올림 */
    .chat-show-page .floating-chat-container {
        bottom: 120px;
    }

    .floating-chat-btn .btn-text {
        display: none;
    }

    .floating-chat-btn {
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 22px;
        justify-content: center;
    }

    .floating-chat-menu {
        left: -100vw;
        left: -100dvw;
        width: 100vw;
        width: 100dvw;
    }

    .floating-chat-menu.show {
        left: 0;
    }

    .floating-chat-header {
        padding: 16px 16px 12px 16px;
        /* safe-area 대응 */
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .floating-chat-list {
        padding: 0 8px 80px 8px;
    }

    .floating-chat-footer {
        padding: 12px 12px 16px 12px;
        padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
    }

    /* 행 버튼 3개 (favorite/rename/delete): 호버 없이 항상 표시 */
    .chat-row-favorite,
    .chat-row-rename,
    .chat-row-delete {
        opacity: 1;
        width: 26px;
        height: 26px;
    }

    /* rename 버튼은 모바일에서 숨김 (인라인 input 입력이 불편) */
    .chat-row-rename {
        display: none;
    }

    /* 제목 폰트 축소 */
    .chat-row-title {
        font-size: 14px;
    }

    .chat-row-meta {
        font-size: 11px;
    }
}
