/* ===== BLADE - Stripe-Inspired Design System ===== */
:root {
    /* Mono color palette - Clean & Professional */
    --accent: #635BFF;
    --accent-hover: #5851EA;
    --accent-subtle: rgba(99, 91, 255, 0.08);
    --accent-muted: rgba(99, 91, 255, 0.12);

    --success: #0A8754;
    --success-bg: rgba(10, 135, 84, 0.08);
    --warning: #E5A910;
    --danger: #DC2626;
    --danger-bg: rgba(220, 38, 38, 0.06);

    /* Backgrounds - Deep & Clean */
    --bg-base: #0A0A0B;
    --bg-surface: #111113;
    --bg-elevated: #18181B;
    --bg-subtle: #1F1F23;
    --bg-muted: #27272A;
    --bg-hover: #2E2E33;

    /* Borders - Subtle */
    --border: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-focus: var(--accent);

    /* Text - High contrast hierarchy */
    --text-primary: #FAFAFA;
    --text-secondary: #A1A1AA;
    --text-tertiary: #71717A;
    --text-muted: #52525B;
    --text-disabled: #3F3F46;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;

    /* Spacing */
    --sidebar-width: 256px;

    /* Radius - Subtle */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows - Minimal */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.35);

    /* Transitions */
    --transition-fast: 80ms ease;
    --transition-base: 150ms ease;
    --transition-slow: 250ms ease;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 28px;
    height: 28px;
}

.brand-logo path:first-of-type {
    fill: var(--accent);
}

.brand-name {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0 8px;
    margin-bottom: 8px;
}

.page-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: border-color var(--transition-base);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%2371717A' stroke-width='1.5'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.page-select:hover {
    border-color: var(--border-focus);
}

.page-select:focus {
    outline: none;
    border-color: var(--accent);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-bottom: 2px;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.5;
}

.nav-item:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.nav-item:hover svg {
    opacity: 0.8;
}

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.nav-item.active svg {
    opacity: 1;
    stroke: var(--accent);
}

.nav-badge {
    margin-left: auto;
    min-width: 24px;
    padding: 2px 8px;
    background: var(--bg-muted);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-align: center;
}

.nav-badge.highlight {
    background: var(--accent);
    color: white;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
}

.btn-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-refresh svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-base);
}

.btn-refresh:hover {
    background: var(--bg-subtle);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-refresh.refreshing svg {
    animation: spin 1s linear infinite;
}

.btn-refresh.refreshing {
    pointer-events: none;
    opacity: 0.7;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-base);
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-title h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-container {
    position: relative;
    width: 280px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.search-container input {
    width: 100%;
    padding: 9px 12px 9px 38px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    transition: all var(--transition-base);
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-surface);
}

.sort-select {
    padding: 9px 32px 9px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%2371717A' stroke-width='1.5'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===== Content ===== */
.content {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

/* ===== States ===== */
.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.loader {
    width: 32px;
    height: 32px;
    border: 2px solid var(--bg-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.state-container p {
    color: var(--text-tertiary);
    margin-top: 12px;
    font-size: 13px;
}

.empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.empty-icon svg {
    width: 100%;
    height: 100%;
}

.state-container h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ===== Comments List ===== */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== Comment Card ===== */
.comment-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    transition: all var(--transition-base);
    cursor: pointer;
}

.comment-card:hover {
    border-color: var(--border-focus);
    background: var(--bg-elevated);
}

.comment-card.unread {
    border-left: 3px solid var(--accent);
}

.comment-card.read {
    opacity: 0.65;
}

.comment-card.read:hover {
    opacity: 1;
}

.comment-card.hidden-comment {
    opacity: 0.4;
    border-left: 3px solid var(--danger);
}

.comment-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.avatar-fallback {
    color: white;
    font-size: 13px;
    font-weight: 600;
}

.author-avatar.small {
    width: 28px;
    height: 28px;
}

.author-avatar.small .avatar-fallback {
    font-size: 11px;
}

.comment-info {
    flex: 1;
    min-width: 0;
}

.comment-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.author-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.page-tag {
    padding: 2px 8px;
    background: var(--bg-muted);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.comment-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.unread {
    background: var(--accent);
}

.status-dot.read {
    background: var(--success);
}

.status-hidden {
    padding: 2px 6px;
    background: var(--danger-bg);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--danger);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.comment-body {
    margin: 12px 0;
    padding-left: 48px;
}

.comment-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    word-break: break-word;
}

.comment-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 48px;
}

.comment-stats {
    display: flex;
    align-items: center;
    gap: 14px;
}

.comment-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.comment-stat svg {
    width: 12px;
    height: 12px;
}

.comment-actions {
    display: flex;
    gap: 6px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-sm svg {
    width: 13px;
    height: 13px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-tertiary);
}

.btn-icon:hover {
    background: var(--bg-subtle);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-icon svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* Mobile-only menu button (drawer toggle) */
.mobile-menu-btn {
    display: none;
}

/* Backdrop used for mobile sidebar drawer */
.sidebar-backdrop {
    display: none;
}

/* ===== Reaction Picker ===== */
.reaction-container {
    position: relative;
}

.btn-reaction:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.reaction-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    display: flex;
    gap: 2px;
    padding: 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 100px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 100;
}

.reaction-picker.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.reaction-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.reaction-btn:hover {
    transform: scale(1.25);
}

.reaction-btn:active {
    transform: scale(1.1);
}

/* ===== Load More ===== */
.load-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px;
    gap: 8px;
}

.btn-load-more {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-load-more svg {
    width: 14px;
    height: 14px;
}

.btn-load-more:hover {
    background: var(--bg-elevated);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.load-more-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 640px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-close:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ===== Thread ===== */
.thread-post {
    padding: 14px 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border-left: 2px solid var(--accent);
}

.thread-post-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.thread-post-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.thread-post-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: opacity var(--transition-fast);
}

.thread-post-link svg {
    width: 12px;
    height: 12px;
}

.thread-post-link:hover {
    opacity: 0.8;
}

.thread-comment {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
}

.thread-comment-content {
    flex: 1;
}

.thread-comment-author {
    font-weight: 600;
    font-size: 13px;
}

.thread-comment-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.thread-comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-top: 8px;
}

.thread-replies {
    margin-left: 48px;
    margin-bottom: 16px;
}

.replies-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.replies-header svg {
    width: 12px;
    height: 12px;
}

.thread-reply {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

.thread-reply:not(:last-child) {
    border-bottom: 1px solid var(--border-subtle);
}

.thread-reply-content {
    flex: 1;
}

.thread-reply-author {
    font-weight: 600;
    font-size: 12px;
}

.thread-reply-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}

.thread-reply-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

.no-replies {
    font-size: 13px;
    color: var(--text-muted);
    padding: 12px 0;
}

.thread-reply-box {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.thread-reply-box textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition-base);
}

.thread-reply-box textarea::placeholder {
    color: var(--text-muted);
}

.thread-reply-box textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.thread-reply-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.2s ease;
    transition: opacity 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.success svg {
    color: var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.error svg {
    color: var(--danger);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Selection ===== */
::selection {
    background: var(--accent-muted);
    color: var(--text-primary);
}

/* ===== Focus States ===== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
    outline: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 220px;
    }

    .main-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
    }

    .search-container {
        flex: 1;
        width: auto;
    }

    .content {
        padding: 16px;
    }

    .comment-body,
    .comment-footer {
        padding-left: 0;
    }
}

@media (max-width: 640px) {
    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-105%);
        transition: transform var(--transition-slow);
        z-index: 900;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
        z-index: 850;
        display: none;
    }

    .sidebar-backdrop.active {
        display: block;
    }

    .modal {
        margin: 10px;
        max-height: 90vh;
    }
}
