/* Thread Style - Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark theme (default, exclusive per v2 design handoff) */
    --color-black: #FFFFFF;
    --color-white: #000000;

    /* Gray Scale */
    --gray-10: #1A1A1A;
    --gray-20: #2A2A2A;
    --gray-30: #666666;
    --gray-40: #B3B3B3;
    --gray-50: #E5E5E5;

    /* Border */
    --border-primary: rgba(255, 255, 255, 0.1);
    --border-divider: #2A2A2A;

    /* Background */
    --bg-primary: #000000;
    --bg-secondary: #1A1A1A;

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --text-muted: #666666;

    /* Accent Colors */
    --accent-blue: #0095F6;
    --accent-red: #E57373;
    --accent-green: #00BA7C;

    /* Workspace avatar palette (cycled by index, text always white) */
    --avatar-1: #FF6B35;
    --avatar-2: #1E3A5F;
    --avatar-3: #E84855;
    --avatar-4: #9B59B6;
    --avatar-5: #00BCD4;
    --avatar-6: #2ECC71;

    /* Dimensions */
    --sidebar-width: 240px;
    --content-max-width: 760px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-full: 50%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.4;
    font-size: 15px;
}

/* Layout Container */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar with Text Labels */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-divider);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 16px;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.sidebar-logo span {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 15px;
}

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

.nav-item.active {
    background: var(--gray-10);
    color: var(--text-primary);
    font-weight: 600;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.nav-item img {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    flex-shrink: 0;
}

.nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-divider);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Hidden elements for Thread style */
.sidebar h3,
.workspace-list,
.btn-add-workspace {
    display: none;
}

/* Main Content Area */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    padding: 0;
}

.content-inner {
    width: 100%;
    min-height: 100vh;
}

/* Only the member-management page's form/list content gets a narrower,
   centered column — other pages fill the full width next to the sidebar. */
.content-inner-narrow {
    max-width: 560px;
    margin: 0 auto;
}

/* Channel page ("chat" layout): the header stays put and only the message
   list itself scrolls, mirroring Slack's own message pane instead of
   scrolling the whole document. flex-direction: column-reverse on the list
   does the rest — the newest message (first in DOM order, unchanged from the
   plain list) ends up at the bottom and is where the pane opens by default,
   and loading older history is a plain DOM append (see loadOlderMessages in
   app.js) instead of a fiddly "insert above + correct scrollTop" dance. */
.content-inner-chat {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.content-inner-chat .message-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    padding-bottom: 0;
}

/* Always present (never display:none) — it doubles as the IntersectionObserver
   sentinel that triggers loading older messages, and an observer can't detect
   a hidden element. min-height keeps it a stable, reliably-observable target
   whether or not it currently has "불러오는 중..." text in it. */
.messages-loading-older {
    min-height: 40px;
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Top Navigation Bar (Thread Style) */
.navbar {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 16px 20px;
    display: none; /* Hidden by default in Thread style */
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-divider);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Page Header */
.page-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    flex: 1;
}

.page-header .logout-btn,
.page-header .btn {
    height: 36px;
    padding: 0 14px;
}

.header-dropdown {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex: 1;
}

.header-dropdown svg {
    width: 16px;
    height: 16px;
}

/* User Info in Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-full);
    object-fit: cover;
}

/* Feed/Message List */
.message-list,
.feed {
    display: flex;
    flex-direction: column;
    padding-bottom: 80px; /* Space for fixed pagination */
}

/* Message Card (Thread Style Post) */
.message {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-divider);
    display: flex;
    gap: 12px;
    transition: background 0.2s;
}

/* Flashed onto the specific message a search "컨텍스트 보기" link scrolled to,
   so it's obvious which one matched instead of leaving the visitor to scan the
   whole page for it. Fades out on its own — no JS cleanup needed. */
@keyframes message-jump-highlight {
    from { background: rgba(245, 158, 11, 0.25); }
    to { background: transparent; }
}

.message-jump-target {
    animation: message-jump-highlight 2.5s ease-out;
}

.message:hover {
    background: var(--gray-10);
}

.message-avatar {
    flex-shrink: 0;
}

.message-avatar img,
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-full);
    object-fit: cover;
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 16px;
    text-transform: uppercase;
}

/* Avatar color palette — 16 visually distinct hues (loosely the Material
   Design color families) so consecutive different senders rarely land on
   the same or a similar-looking color. Combined with the initial-letter
   text in the markup, so even a color repeat (bound to happen once a
   channel has more than ~16 distinct senders) still reads as a different
   person. */
.avatar-color-0 { background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%); }
.avatar-color-1 { background: linear-gradient(135deg, #1E3A5F 0%, #2E5077 100%); }
.avatar-color-2 { background: linear-gradient(135deg, #E84855 0%, #FF6B6B 100%); }
.avatar-color-3 { background: linear-gradient(135deg, #F9A825 0%, #FFD54F 100%); }
.avatar-color-4 { background: linear-gradient(135deg, #2ECC71 0%, #58D68D 100%); }
.avatar-color-5 { background: linear-gradient(135deg, #9B59B6 0%, #BB8FCE 100%); }
.avatar-color-6 { background: linear-gradient(135deg, #00BCD4 0%, #4DD0E1 100%); }
.avatar-color-7 { background: linear-gradient(135deg, #607D8B 0%, #90A4AE 100%); }
.avatar-color-8 { background: linear-gradient(135deg, #E91E63 0%, #F48FB1 100%); }
.avatar-color-9 { background: linear-gradient(135deg, #3F51B5 0%, #7986CB 100%); }
.avatar-color-10 { background: linear-gradient(135deg, #009688 0%, #4DB6AC 100%); }
.avatar-color-11 { background: linear-gradient(135deg, #795548 0%, #A1887F 100%); }
.avatar-color-12 { background: linear-gradient(135deg, #673AB7 0%, #9575CD 100%); }
.avatar-color-13 { background: linear-gradient(135deg, #8BC34A 0%, #AED581 100%); }
.avatar-color-14 { background: linear-gradient(135deg, #D84315 0%, #FF8A65 100%); }
.avatar-color-15 { background: linear-gradient(135deg, #1976D2 0%, #64B5F6 100%); }

.avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.message-user {
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.message-user:hover {
    text-decoration: underline;
}

.verified-badge {
    width: 16px;
    height: 16px;
    color: var(--accent-blue);
}

.message-time {
    color: var(--text-muted);
    font-size: 14px;
}

.message-time::before {
    content: "·";
    margin: 0 4px;
}

.message-workspace,
.message-channel {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--gray-10);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    margin-left: 8px;
}

.message-text {
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Code blocks */
.code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    margin: 8px 0;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-block code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.inline-code {
    background: #f0f0f0;
    color: #e83e8c;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
}

/* Message Actions (Like, Comment, Repost, Share) */
.message-actions {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    border-radius: var(--border-radius-full);
    transition: all 0.2s;
    font-size: 13px;
}

.action-btn:hover {
    background: var(--gray-10);
}

.action-btn:hover .icon-heart {
    color: var(--accent-red);
}

.action-btn:hover .icon-comment {
    color: var(--accent-blue);
}

.action-btn:hover .icon-repost {
    color: var(--accent-green);
}

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

/* Message Thread Indicator */
.message-thread {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--gray-10);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.message-reactions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Slack-style file/image attachments — see renderFilesHTML (server.go) and
   its JS mirror in app.js. */
.message-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.file-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-10);
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-md, 8px);
    font-size: 13px;
    max-width: 320px;
}

.file-card-image {
    padding: 0;
    border: 1px solid var(--border-divider);
    overflow: hidden;
    display: inline-block;
}

.file-thumb {
    display: block;
    max-width: 280px;
    max-height: 220px;
    object-fit: contain;
}

.file-card-video {
    position: relative;
    padding: 0;
    border: 1px solid var(--border-divider);
    overflow: hidden;
    max-width: none;
    display: inline-block;
}

.file-video-expand {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    color: #fff;
    font-size: 15px;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

.file-video-expand:hover {
    background: rgba(0, 0, 0, 0.75);
}

.file-video {
    display: block;
    max-width: 320px;
    max-height: 240px;
}

.file-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.file-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-download-link {
    color: var(--accent-blue);
    text-decoration: none;
    flex-shrink: 0;
    margin-left: auto;
}

.file-download-link:hover {
    text-decoration: underline;
}

.file-backup-btn {
    background: none;
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    padding: 3px 8px;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
}

.file-backup-btn:hover {
    background: var(--accent-blue);
    color: #fff;
}

.file-backup-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.file-card-unavailable .file-name,
.file-card-unavailable .file-size {
    color: var(--text-muted);
}

.file-status-label {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
    margin-left: auto;
}

.reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--gray-10);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    cursor: default;
}

.reaction-emoji {
    font-size: 14px;
    line-height: 1;
}

.reaction-emoji-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
}

.reaction-count {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Compose Box */
.compose-box {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-divider);
    display: flex;
    gap: 12px;
}

.compose-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    color: var(--text-primary);
    resize: none;
    outline: none;
}

.compose-input::placeholder {
    color: var(--text-muted);
}

.compose-btn {
    padding: 8px 16px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.compose-btn:hover {
    opacity: 0.8;
}

.compose-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Search Page (Thread Style) */
.search-container {
    padding: 16px 20px;
}

.search-form {
    margin-bottom: 0;
}

.search-input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    padding-left: 44px;
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-lg);
    font-size: 15px;
    background: var(--gray-10);
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--text-primary);
}

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-select {
    padding: 12px 16px;
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-lg);
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Global input styles */
input, textarea, select {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

.search-tips {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
}

.search-tips h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.search-tips ul {
    list-style: none;
}

.search-tips li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-divider);
    font-size: 14px;
    color: var(--text-secondary);
}

.search-tips li:last-child {
    border-bottom: none;
}

/* Follow Suggestions */
.suggestions {
    padding: 16px 20px;
}

.suggestions-title {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.suggestion-info {
    flex: 1;
}

.suggestion-name {
    font-weight: 600;
    font-size: 14px;
}

.suggestion-handle {
    font-size: 14px;
    color: var(--text-muted);
}

.follow-btn {
    padding: 8px 16px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.follow-btn:hover {
    opacity: 0.9;
}

/* Stats Grid (Dashboard) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--border-divider);
    border-bottom: 1px solid var(--border-divider);
}

.stat-card {
    background: var(--bg-primary);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* Info Section */
.info-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
}

.info-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.info-section p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.info-section p:last-child {
    margin-bottom: 0;
}

/* Channel List */
.channel-list {
    display: flex;
    flex-direction: column;
}

.channel-card {
    display: flex;
    align-items: center;
    padding: 0 20px 0 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-divider);
    transition: background 0.2s, opacity 0.2s, transform 0.2s;
}

.channel-card:hover {
    background: var(--gray-10);
}

.channel-link {
    display: flex;
    align-items: center;
    flex: 1;
    padding: 16px 0 16px 20px;
    text-decoration: none;
    color: inherit;
}

.channel-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-10);
    border-radius: var(--border-radius-full);
    margin-right: 12px;
    font-size: 18px;
}

.channel-info {
    flex: 1;
}

.channel-name {
    font-weight: 600;
    font-size: 15px;
}

.channel-purpose {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

.channel-count {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 12px;
    background: var(--gray-10);
    border-radius: var(--border-radius-lg);
}

/* Sync Toggle Switch */
.sync-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin-left: 12px;
    cursor: pointer;
}

.sync-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sync-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-20);
    border-radius: var(--border-radius-lg);
    transition: 0.3s;
}

.sync-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sync-toggle input:checked + .sync-slider {
    background-color: var(--accent-green);
}

.sync-toggle input:checked + .sync-slider:before {
    transform: translateX(20px);
}

.sync-toggle input:disabled + .sync-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty state inline for channel sections */
.empty-state-inline {
    padding: 24px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    border-bottom: 1px solid var(--border-divider);
}

.empty-state-inline p {
    margin: 0;
}

/* Hide empty state when there are synced channels */
#synced-channels .channel-card ~ .empty-state-inline {
    display: none;
}

/* Hide empty state when there are DMs */
#dm-channels .dm-card ~ .empty-state-inline {
    display: none;
}

/* DM card styling */
.dm-card {
    background: var(--bg-tertiary);
}

.dm-card .channel-name {
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    opacity: 0.85;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-divider);
}

.btn-secondary:hover {
    background: var(--gray-10);
}

.btn.disabled,
.btn-secondary.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-danger {
    background: var(--accent-red);
    color: var(--bg-primary);
}

.btn-danger:hover {
    opacity: 0.85;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-divider);
    background: var(--bg-primary);
    position: fixed;
    bottom: 0;
    left: 280px;
    right: 0;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.page-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
}

.page-num:hover {
    background: var(--gray-20);
    color: var(--text-primary);
}

.page-num.active {
    background: var(--accent-blue);
    color: white;
    font-weight: 600;
}

.page-ellipsis {
    color: var(--text-muted);
    padding: 0 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    margin-bottom: 20px;
}

/* Error */
.error-view {
    text-align: center;
    padding: 60px 20px;
}

.error-box {
    background: #FEF2F2;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 16px;
    border-radius: var(--border-radius-md);
    margin: 16px 0;
}

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 16px 20px;
}

.back-link:hover {
    color: var(--text-primary);
}

.back-link svg {
    width: 20px;
    height: 20px;
}

/* Channel Header */
.channel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
}

.channel-header h1 {
    font-size: 20px;
    font-weight: 700;
}

.channel-topic {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* Workspace Header */
.workspace-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.workspace-title {
    flex: 1;
    min-width: 0;
}

.workspace-title h1 {
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-domain {
    color: var(--text-muted);
    font-size: 14px;
}

.sync-schedule-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}

.workspace-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.workspace-actions .btn,
.workspace-actions .logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    white-space: nowrap;
}

/* Quick Actions */
.quick-actions {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
}

.quick-actions h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* No Data */
.no-data {
    color: var(--text-muted);
    font-style: normal;
    padding: 20px;
    text-align: center;
}

/* View Context Link */
.view-context {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--accent-blue);
    text-decoration: none;
}

.view-context:hover {
    text-decoration: underline;
}

/* Messages Header */
.messages-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-divider);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.messages-header h2 {
    font-size: 16px;
    font-weight: 600;
}

/* Dashboard */
.dashboard h1 {
    padding: 20px;
    font-size: 24px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-divider);
}

/* Login Page */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* Admin Page */
.admin-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
}

.admin-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-divider);
    font-size: 14px;
}

.admin-table th {
    font-weight: 600;
    color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        flex-direction: row;
        justify-content: space-around;
        padding: 8px 0;
        border-top: 1px solid var(--border-divider);
        border-right: none;
        overflow-x: auto;
    }

    .sidebar-logo {
        display: none;
    }

    .sidebar-section-title {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 0;
        width: 100%;
        justify-content: space-around;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        font-size: 10px;
    }

    .nav-item span {
        display: none;
    }

    .nav-item svg,
    .nav-item img {
        width: 24px;
        height: 24px;
    }

    .sidebar-bottom {
        display: none;
    }

    .content {
        margin-left: 0;
        margin-bottom: 64px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .workspace-header {
        flex-direction: column;
    }

    .message-actions {
        gap: 8px;
    }
}

/* Workspace List in Sidebar (for non-icon mode) */
.workspace-sidebar {
    display: none;
}

/* Nav links styling */
.nav-links {
    display: none;
}

.nav-brand {
    display: none;
}

/* Logout button */
.btn-logout {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    text-decoration: none;
}

.btn-logout:hover {
    background: var(--gray-10);
}

/* Nav admin link */
.nav-admin {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.nav-admin:hover {
    text-decoration: underline;
}

/* User profile in sidebar (non-clickable) */
.user-profile {
    cursor: default;
}

.user-profile:hover {
    background: transparent;
}

/* Logout button in header */
.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    background: transparent;
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: var(--gray-10);
    color: var(--text-primary);
}

/* Back link inline in header */
.back-link-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    margin-right: 8px;
}

.back-link-inline:hover {
    background: var(--gray-10);
    color: var(--text-primary);
}

.back-link-inline svg {
    width: 18px;
    height: 18px;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--gray-10);
    color: var(--text-primary);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--border-radius-md);
    width: 100%;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-divider);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-10);
    color: var(--text-primary);
}

.modal-content form {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--text-primary);
    background: var(--bg-primary);
}

.form-error {
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid var(--accent-red);
    border-radius: var(--border-radius-sm);
    color: var(--accent-red);
    font-size: 14px;
    margin-bottom: 16px;
}

.form-success {
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid var(--accent-green);
    border-radius: var(--border-radius-sm);
    color: var(--accent-green);
    font-size: 14px;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 8px;
}

.form-error {
    background: rgba(232, 72, 85, 0.1);
}

.form-success {
    background: rgba(0, 186, 124, 0.1);
}

/* ==================== v2 Onboarding Redesign Components ==================== */

/* Common two-row page header (screens ⑤⑥⑦⑧) */
.page-header-two-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-header-back-row {
    min-height: 20px;
    margin-bottom: 12px;
}

.page-header-title-row {
    align-items: flex-start;
}

.page-header-title-group {
    min-width: 0;
}

.page-header-title-group h1,
.page-header-title-group .page-title {
    font-size: 20px;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.back-link {
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: none;
}

.back-link:hover {
    color: var(--text-secondary);
}

/* Alert banner (success / warning / error) — shared across all authenticated screens */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(0, 186, 124, 0.12);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.14);
    border-color: #F59E0B;
    color: #F59E0B;
}

.alert-error {
    background: rgba(232, 72, 85, 0.12);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

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

/* Admin section (workspace & bot management, member/admin management page) */
.admin-section {
    padding: 20px 0;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.admin-section-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.admin-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 24px 0 12px;
}

.admin-section h4:first-child {
    margin-top: 0;
}

.admin-workspace-card {
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-workspace-card h3 {
    font-size: 15px;
    font-weight: 600;
}

.admin-member-list {
    list-style: none;
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    margin-bottom: 12px;
}

.admin-member-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-divider);
}

.admin-member-list li:last-child {
    border-bottom: none;
}

.admin-member-list li button {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border-divider);
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}

.admin-member-list li button:hover {
    background: var(--gray-10);
    color: var(--text-primary);
}

/* Channel/group-DM/DM management rows: name stays left-aligned, every switch,
   badge, and button that controls that row is grouped together and pushed to
   the right edge as one unit — instead of drifting based on which controls
   happen to be present for a given row. */
.admin-member-list li .admin-item-name {
    flex: 1 1 auto;
    min-width: 0;
}

.admin-member-list li .channel-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.admin-member-list li .channel-controls button {
    margin-left: 0;
}

/* Warning shown under a channel's name when sync is on but the bot isn't
   actually a member — sync_enabled alone doesn't guarantee backups happen. */
.admin-member-list li .channel-warning {
    margin: 4px 0 0;
    font-size: 12px;
    color: #F59E0B;
}

/* Member vs. admin distinguishing icon (gray dot for member, blue star-dot for admin) */
.member-list-icon {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--border-radius-full);
    flex-shrink: 0;
}

.member-list-icon-member {
    background: var(--text-muted);
}

.member-list-icon-admin {
    background: var(--accent-blue);
}

/* Why a member has access, and whether Slack's roster still confirms them.
   "미확인" is deliberately not auto-revoked — a partial users.list looks the same
   as a departure — so this badge is the only path to a human noticing. */
.member-badge {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 6px;
    border-radius: var(--border-radius-full);
    font-size: 11px;
    line-height: 16px;
    vertical-align: middle;
}

.member-badge-auto {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.member-badge-warn {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

.admin-inline-form {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.admin-inline-form input[type="email"] {
    flex: 1;
    padding: 10px 14px;
    background: var(--gray-10);
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.admin-inline-form input[type="email"]:focus {
    outline: none;
    border-color: var(--text-primary);
}

.admin-inline-form button {
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.admin-inline-form button:hover {
    opacity: 0.85;
}

.admin-inline-form .btn-appoint-admin {
    background: var(--accent-blue);
    color: #FFFFFF;
}

/* Dashboard workspace card list (auto / granted sections) */
.workspace-card-list {
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    margin-bottom: 12px;
}

.workspace-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-divider);
    text-decoration: none;
    color: inherit;
}

.workspace-card:last-child {
    border-bottom: none;
}

.workspace-card:hover {
    background: var(--gray-10);
}

.workspace-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.workspace-avatar-0 { background: var(--avatar-1); }
.workspace-avatar-1 { background: var(--avatar-2); }
.workspace-avatar-2 { background: var(--avatar-3); }
.workspace-avatar-3 { background: var(--avatar-4); }
.workspace-avatar-4 { background: var(--avatar-5); }
.workspace-avatar-5 { background: var(--avatar-6); }

.workspace-card-info {
    flex: 1;
    min-width: 0;
}

.workspace-card-name {
    font-size: 15px;
    font-weight: 600;
}

.workspace-card-status {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.workspace-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--border-radius-full);
    flex-shrink: 0;
    white-space: nowrap;
}

.workspace-badge-auto {
    background: var(--gray-10);
    color: var(--text-secondary);
}

.workspace-badge-granted {
    background: rgba(0, 149, 246, 0.15);
    color: var(--accent-blue);
}

/* Bot-not-installed activation banner on the dashboard */
.activation-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--gray-10);
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.activation-banner p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Sync progress banner: a "메시지 가져오기" run happens in the background (see
   handleFetchWorkspace/handleSyncStatus in Go, initSyncStatusPolling in
   app.js) so it can outlive a reverse proxy's request timeout on a large
   first sync. This banner is fixed at the top of every page (see base.html)
   and polls for progress, so it keeps reporting status even if the user
   navigates elsewhere while the sync is still running. */
.sync-progress-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gray-10);
    border-bottom: 1px solid var(--border-divider);
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sync-progress-bar {
    width: 120px;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-20);
    overflow: hidden;
    flex-shrink: 0;
}

.sync-progress-bar-fill {
    height: 100%;
    width: 30%;
    background: var(--accent-blue);
    border-radius: 2px;
    animation: sync-progress-indeterminate 1.2s ease-in-out infinite;
}

.sync-progress-banner.done .sync-progress-bar-fill {
    width: 100%;
    animation: none;
    background: var(--accent-green);
}

.sync-progress-banner.error .sync-progress-bar-fill {
    width: 100%;
    animation: none;
    background: var(--accent-red);
}

@keyframes sync-progress-indeterminate {
    0% { margin-left: 0; width: 20%; }
    50% { margin-left: 60%; width: 40%; }
    100% { margin-left: 100%; width: 5%; }
}

.sync-progress-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 4px;
}

.sync-progress-dismiss:hover {
    color: var(--text-primary);
}

/* Pushes the fixed sidebar/content down while the banner above is visible
   (toggled on <body> by showSyncBanner/hideSyncBanner in app.js) so it
   doesn't sit on top of the sidebar logo — both .sidebar and .content are
   already position:fixed/full-height, so simple document flow can't do this. */
body.has-sync-banner .sidebar {
    top: 44px;
}

body.has-sync-banner .content {
    padding-top: 44px;
}
