/* AnnotaHub Custom Styles */
:root {
    --app-bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --surface-soft: #f8fafc;
    --surface-border: rgba(15, 23, 42, 0.08);
    --ink: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --accent: #14b8a6;
    --danger: #dc3545;
    --warning: #f59e0b;
    --success: #16a34a;
    --sidebar-bg: linear-gradient(180deg, #081120 0%, #0f1b33 100%);
}

body {
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 34%),
        radial-gradient(circle at top right, rgba(20, 184, 166, 0.10), transparent 30%),
        var(--app-bg);
    color: var(--ink);
}

.app-shell {
    min-height: 100vh;
}

.app-main {
    padding: 1.25rem;
}

.page-frame {
    max-width: 1680px;
    margin: 0 auto;
}

.sidebar {
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    position: sticky;
    top: 0;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.sidebar-inner {
    gap: 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.10);
    font-size: 1.1rem;
}

.sidebar-subtitle {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.82rem;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.78);
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 600;
    transition: all 0.18s ease;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-footer {
    padding-top: 0.5rem;
}

.sidebar-user {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    padding: 0.85rem 1rem;
}

.sidebar-footnote {
    color: rgba(255, 255, 255, 0.45);
}

.lang-flag-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    transition: all 0.18s ease;
}

.lang-flag-btn:hover,
.lang-flag-btn.active {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

.btn-logout {
    background: rgba(220, 53, 69, 0.18);
    color: #ffd5da;
    border: 1px solid rgba(220, 53, 69, 0.32);
    border-radius: 0.9rem;
    padding: 0.7rem 1rem;
    font-weight: 600;
    transition: all 0.18s ease;
}

.btn-logout:hover {
    background: rgba(220, 53, 69, 0.32);
    color: #fff;
}

/* Ensure comment text preserves spacing */
.comment-text {
    white-space: pre-wrap;
    line-height: 1.7;
    font-size: 0.98rem;
}

/* Add space between token words */
.token-word::after {
    content: "";
}

/* Token word hover effect */
.token-word:hover {
    outline: 2px solid rgba(13, 110, 253, 0.15);
}

/* Status badges */
.badge {
    font-weight: 500;
}

/* Card hover shadow */
.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: 1.15rem;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.09);
}

/* Sidebar link hover */
.sidebar .nav-link i {
    margin-right: 0.5rem;
}

/* Progress bar animation */
.progress-bar {
    transition: width 0.6s ease;
}

.progress {
    background-color: rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    overflow: hidden;
}

.progress-thin {
    height: 0.45rem;
}

/* Responsive video embed */
.video-embed-container {
    aspect-ratio: 16 / 9;
    width: 100%;
    overflow: hidden;
    border-radius: 0.75rem;
    background: #000;
}

.video-embed-container iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.video-shell {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.96) 100%);
}

.video-panel {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: 1rem;
}

.comment-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1.1rem;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.comment-card .card-body {
    padding: 1rem 1.1rem;
}

.comment-avatar {
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.comment-avatar-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    flex: 0 0 auto;
}

.comment-author {
    font-size: 0.98rem;
}

.comment-original {
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
}

.token-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.28rem;
    align-items: center;
}

.token-word {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: #eef2f7;
    border: 1px solid rgba(15, 23, 42, 0.08);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-size: 0.84rem;
    line-height: 1.1;
}

.token-score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.28rem;
    padding: 0.05rem 0.28rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: #334155;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
}

.token-word.toxic {
    background: rgba(220, 53, 69, 0.14);
    border-color: rgba(220, 53, 69, 0.35);
    color: #9f1239;
    font-weight: 600;
}

.token-word.toxic .token-score-badge {
    background: rgba(255, 255, 255, 0.26);
    color: inherit;
}

.comment-card.label-meaningless {
    background: #f8f9fa;
    border-color: rgba(108, 117, 125, 0.2);
}

.comment-side-panel {
    height: 100%;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    padding-left: 1rem;
}

.comment-actions {
    display: block;
    padding: 0.75rem 0.85rem;
    border-radius: 0.85rem;
    background: rgba(248, 250, 252, 0.95);
    border: 1px dashed rgba(15, 23, 42, 0.09);
}

@media (max-width: 991.98px) {
    .comment-side-panel {
        border-left: 0;
        padding-left: 0;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        padding-top: 1rem;
    }
}

/* Alert auto-dismiss */
.alert {
    animation: fadeIn 0.3s ease-in;
}

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

/* Pagination */
.pagination .page-link {
    color: #0d6efd;
}

.pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* ============================================
   Bootstrap Popover - Token Label Menu
   ============================================ */

/* Ensure Bootstrap popover is properly positioned */
.popover {
    z-index: 10000;
    border-radius: 0.9rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 1rem 2rem rgba(15, 23, 42, 0.18);
}

.popover .popover-body {
    padding: 0.4rem 0;
}

.token-label-popover {
    min-width: 190px;
    max-width: 290px;
}

.token-label-popover-header {
    padding: 0.25rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 0.3rem;
}

.token-label-popover-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.85rem;
    cursor: pointer !important;
    font-size: 0.88rem;
    transition: background-color 0.12s ease, border-left-color 0.12s ease;
    border-radius: 0;
    border-left: 4px solid transparent;
    user-select: none;
    -webkit-user-select: none;
}

.token-label-popover-item:hover {
    background-color: #eef2ff;
}

.token-label-popover-item:active {
    background-color: #e0e7ff;
}

.token-score-panel {
    padding: 0.65rem 0.85rem 0.8rem;
    margin-top: 0.35rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
}

.token-score-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.55rem;
}

.token-score-chip {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #fff;
    color: #334155;
    border-radius: 999px;
    padding: 0.22rem 0.55rem;
    font-size: 0.76rem;
    font-weight: 700;
    transition: all 0.15s ease;
}

.token-score-chip:hover {
    border-color: rgba(37, 99, 235, 0.35);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.token-score-range {
    margin-bottom: 0.2rem;
}

.page-hero,
.surface-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 1.2rem;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.06);
}

.page-hero {
    padding: 1.25rem 1.4rem;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-title h5,
.section-title h4 {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.section-title p {
    margin: 0;
    color: var(--muted);
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-2);
    font-weight: 600;
    font-size: 0.82rem;
}

.empty-state {
    background: var(--surface);
    border: 1px dashed rgba(15, 23, 42, 0.12);
    border-radius: 1.2rem;
    padding: 2.5rem 1.5rem;
}

.table > :not(caption) > * > * {
    padding: 0.9rem 0.85rem;
}

@media (max-width: 991.98px) {
    .sidebar {
        min-height: auto;
        position: relative;
    }

    .app-main {
        padding: 0.9rem;
    }

    .page-hero,
    .surface-card {
        border-radius: 1rem;
    }
}

.token-label-popover-item .label-color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0, 0, 0, 0.12);
}

.token-label-popover-item .label-color-none {
    background-color: #e9ecef !important;
    border: 2px dashed #adb5bd !important;
}

.token-label-popover-item .label-name {
    font-weight: 500;
}

.token-label-popover-none {
    color: #6c757d;
    font-style: italic;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: 0.2rem;
    padding-top: 0.35rem 0.5rem;
    border-left: 4px solid transparent !important;
}

.token-label-popover-none:hover {
    background-color: #f8f9fa;
}

/* ============================================
   Token with applied manual label
   ============================================ */
.token-word.token-labeled {
    box-shadow: 0 0 0 1px var(--token-label-color, transparent);
}

/* ============================================
   Comment label buttons
   ============================================ */
.comment-label-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    border-width: 1px;
    border-style: solid;
    transition: all 0.15s ease;
}

.comment-label-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.comment-label-btn.active-label-btn {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.comment-label-btn .label-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
