/* ============================================================
   SupportHub Portal — Modern customer-facing theme
   Inspired by Zendesk / Intercom
   ============================================================ */

:root {
    --portal-bg:           #f5f7fa;
    --portal-surface:      #ffffff;
    --portal-border:       #e5e7eb;
    --portal-text:         #1f2937;
    --portal-text-muted:   #6b7280;
    --portal-accent:       #4f46e5;
    --portal-accent-hover: #4338ca;
    --portal-accent-light: #eef2ff;
    --portal-radius:       12px;
    --portal-radius-lg:    16px;
    --portal-shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --portal-shadow-hover: 0 8px 25px rgba(0,0,0,.08);
}

/* ── Base ── */
body {
    background: var(--portal-bg);
    color: var(--portal-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: .9375rem;
    line-height: 1.6;
}

a { color: var(--portal-accent); text-decoration: none; }
a:hover { color: var(--portal-accent-hover); }

/* ── Brand ── */
.brand-icon {
    width: 2.25rem; height: 2.25rem;
    background: linear-gradient(135deg, var(--portal-accent), #818cf8);
    border-radius: .625rem;
    display: grid; place-items: center;
    color: #fff; font-size: 1.1rem; flex-shrink: 0;
}

/* ── Navbar ── */
.navbar {
    background: var(--portal-surface) !important;
    padding: .5rem 0;
}
.navbar .nav-link {
    color: var(--portal-text-muted);
    font-size: .875rem; font-weight: 500;
    padding: .5rem 1rem; border-radius: 8px;
    transition: all .15s;
}
.navbar .nav-link:hover { color: var(--portal-accent); background: var(--portal-accent-light); }
.navbar .nav-link.active { color: var(--portal-accent); background: var(--portal-accent-light); font-weight: 600; }

/* ── Scroll offset for sticky navbar ── */
[id^="sec-"], [id^="cat-"], [id^="section-"] {
    scroll-margin-top: 80px;
}

/* ── Main ── */
.portal-main { min-height: calc(100vh - 120px); }
.portal-footer { background: transparent; }

/* ── Cards ── */
.card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    overflow: hidden;
}
.card-header {
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
    padding: 1rem 1.25rem;
}
.card-header h6 { font-weight: 600; font-size: .9rem; margin: 0; }

/* ── Stat Cards (KPI) ── */
.stat-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--portal-shadow);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--portal-shadow-hover);
}
.stat-icon {
    width: 3rem; height: 3rem;
    border-radius: .75rem;
    display: grid; place-items: center;
    font-size: 1.35rem;
}
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--portal-text-muted); margin-top: .25rem; font-weight: 500; }

/* ── Ticket Cards (dashboard list) ── */
.ticket-card {
    display: block;
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: .75rem;
    text-decoration: none;
    color: var(--portal-text);
    transition: all .2s;
    box-shadow: var(--portal-shadow);
}
.ticket-card:hover {
    border-color: var(--portal-accent);
    box-shadow: var(--portal-shadow-hover);
    transform: translateY(-1px);
    color: var(--portal-text);
}

/* ── Filter pills ── */
.filter-pill {
    display: inline-flex; align-items: center;
    border-radius: 20px; font-size: .8rem; padding: 6px 16px;
    border: 1px solid var(--portal-border);
    color: var(--portal-text-muted);
    background: var(--portal-surface);
    cursor: pointer; transition: all .15s;
    font-weight: 500;
}
.filter-pill:hover { border-color: var(--portal-accent); color: var(--portal-accent); }
.filter-pill.active { background: var(--portal-accent); border-color: var(--portal-accent); color: #fff; }

/* ── Status progress bar ── */
.status-progress {
    display: flex; align-items: center; gap: 0; width: 100%;
}
.status-step {
    display: flex; flex-direction: column; align-items: center; flex: 1; position: relative;
    font-size: .7rem; color: var(--portal-text-muted);
}
.status-step .step-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--portal-border);
    border: 2px solid var(--portal-border);
    z-index: 1; transition: all .2s;
}
.status-step.done .step-dot { background: var(--portal-accent); border-color: var(--portal-accent); }
.status-step.current .step-dot { background: #fff; border-color: var(--portal-accent); box-shadow: 0 0 0 3px var(--portal-accent-light); }
.status-step .step-line {
    position: absolute; top: 4px; left: 50%; width: 100%; height: 2px;
    background: var(--portal-border); z-index: 0;
}
.status-step.done .step-line { background: var(--portal-accent); }
.status-step:last-child .step-line { display: none; }
.status-step .step-label { margin-top: 6px; text-align: center; line-height: 1.2; }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 2.5rem; }
.timeline::before {
    content: ''; position: absolute; left: 1.125rem; top: 0; bottom: 0;
    width: 2px; background: var(--portal-border);
}
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-avatar {
    position: absolute; left: -2.5rem; top: 0;
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: .75rem; font-weight: 700; color: #fff;
    z-index: 1;
}
.timeline-avatar.agent { background: var(--portal-accent); }
.timeline-avatar.client { background: #f59e0b; }
.timeline-content {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1rem 1.25rem;
}
.timeline-content.agent-msg {
    background: var(--portal-accent-light);
    border-color: #c7d2fe;
    border-left: 3px solid var(--portal-accent);
}
.timeline-meta {
    font-size: .78rem; color: var(--portal-text-muted);
    margin-bottom: .5rem;
}
.timeline-meta strong { color: var(--portal-text); }
.timeline-body { font-size: .9rem; line-height: 1.7; overflow-x: auto; word-wrap: break-word; }
.timeline-body img { max-width: 100%; height: auto; border-radius: 6px; }
.timeline-body table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .85rem; }
.timeline-body table td, .timeline-body table th { border: 1px solid #e2e8f0; padding: 6px 10px; }
.timeline-body table th { background: #f8fafc; font-weight: 600; }

/* ── Info rows ── */
.info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: .625rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.info-row:last-child { border-bottom: none; }

/* ── Reply box ── */
.reply-box {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.25rem;
}
.reply-box textarea {
    border: 1px solid var(--portal-border);
    border-radius: 8px; resize: vertical;
    font-size: .9rem; padding: .75rem 1rem;
    width: 100%;
}
.reply-box textarea:focus {
    outline: none;
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px var(--portal-accent-light);
}

/* ── Environment banner ── */
.env-banner {
    font-size: .65rem; font-weight: 700;
    text-align: center; padding: 2px 0;
    letter-spacing: .1em; z-index: 9999;
}

/* ── Breadcrumb ── */
.breadcrumb { font-size: .82rem; }

/* ── Forms ── */
.form-label { font-size: .875rem; font-weight: 500; }
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--portal-border);
    padding: .5rem .875rem;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px var(--portal-accent-light);
}

/* ── Buttons ── */
.btn { border-radius: 8px; font-weight: 500; font-size: .875rem; }
.btn-primary {
    background: var(--portal-accent);
    border-color: var(--portal-accent);
}
.btn-primary:hover {
    background: var(--portal-accent-hover);
    border-color: var(--portal-accent-hover);
}
.btn-lg { padding: .625rem 1.5rem; font-size: 1rem; }

/* ── Code ── */
code {
    color: var(--portal-accent);
    background: var(--portal-accent-light);
    padding: .125rem .5rem;
    border-radius: 6px; font-size: .8rem;
}

/* ── Badges ── */
.badge { border-radius: 6px; font-weight: 600; font-size: .75rem; }

/* ── Misc ── */
.cursor-pointer { cursor: pointer; }
.ticket-description { font-size: .9rem; line-height: 1.7; overflow-x: auto; }
.ticket-description img { max-width: 100%; border-radius: 8px; }
.ticket-description table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .85rem; }
.ticket-description table td, .ticket-description table th { border: 1px solid #e2e8f0; padding: 6px 10px; text-align: left; }
.ticket-description table th { background: #f8fafc; font-weight: 600; }

/* ── SHEditor (TipTap) ── */
.sh-editor-wrapper { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.sh-editor-toolbar { background: #f8fafc; border-bottom: 1px solid #e2e8f0; padding: 4px 6px; display: flex; flex-wrap: wrap; gap: 2px; }
.sh-editor-btn-group { display: inline-flex; gap: 1px; margin-right: 4px; }
.sh-editor-toolbar button { background: transparent; border: none; color: #64748b; padding: 4px 7px; border-radius: 4px; cursor: pointer; font-size: .82rem; line-height: 1; display: inline-flex; align-items: center; gap: 2px; }
.sh-editor-toolbar button:hover { background: #e2e8f0; color: #1e293b; }
.sh-editor-toolbar button.active { background: #e0e7ff; color: #4f46e5; }
.sh-editor-content .tiptap { padding: 10px 14px; outline: none; color: #1e293b; font-size: .9rem; line-height: 1.6; min-height: 100px; border: none !important; }
.sh-editor-content .tiptap:focus { outline: none; }
.sh-editor-content .ProseMirror { outline: none !important; }
.sh-editor-content .tiptap p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: #94a3b8; pointer-events: none; float: left; height: 0; }
.sh-editor-content .tiptap table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.sh-editor-content .tiptap table td, .sh-editor-content .tiptap table th { border: 1px solid #e2e8f0; padding: 6px 10px; }
.sh-editor-content .tiptap table th { background: #f8fafc; font-weight: 600; }
.sh-editor-content .tiptap table .selectedCell { background: #e0e7ff; }
.sh-editor-content .tiptap a { color: #4f46e5; }
.sh-editor-content .tiptap img { max-width: 100%; height: auto; border-radius: 6px; margin: 4px 0; }
.sh-editor-content .tiptap ul, .sh-editor-content .tiptap ol { padding-left: 1.5rem; }
.sh-editor-content .tiptap pre { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: .75rem; }
.sh-editor-content .tiptap mark { background: rgba(250,204,21,.3); border-radius: 2px; padding: 0 2px; }
.sh-editor-content .tiptap hr { border: none; border-top: 2px solid #e2e8f0; margin: 1rem 0; }
.sh-editor-content .tiptap ul[data-type="taskList"] { list-style: none; padding-left: 0; }
.sh-editor-content .tiptap ul[data-type="taskList"] li { display: flex; align-items: flex-start; gap: 6px; }
.sh-editor-content .tiptap ul[data-type="taskList"] li label { flex-shrink: 0; margin-top: 2px; }
.sh-editor-content .tiptap ul[data-type="taskList"] li[data-checked="true"] > div > p { text-decoration: line-through; color: #94a3b8; }
.sh-editor-content .tiptap code { background: #f1f5f9; color: #6366f1; padding: 1px 4px; border-radius: 3px; font-size: .85em; }
.sh-editor-footer { font-size: .7rem; color: #94a3b8; padding: 2px 10px 4px; text-align: right; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.sh-mention { background: #e0e7ff; color: #4f46e5; border-radius: 3px; padding: 0 3px; font-weight: 500; }
.sh-mention-dropdown { position: fixed; z-index: 9999; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.sh-mention-item { display: block; width: 100%; text-align: left; padding: 6px 12px; border: none; background: transparent; color: #1e293b; font-size: .82rem; cursor: pointer; }
.sh-mention-item:hover { background: #e0e7ff; }
.timeline-body mark { background: rgba(250,204,21,.3); border-radius: 2px; padding: 0 2px; }
.timeline-body code { background: #f1f5f9; color: #6366f1; padding: 1px 4px; border-radius: 3px; font-size: .85em; }
.timeline-body .sh-mention { background: #e0e7ff; color: #4f46e5; border-radius: 3px; padding: 0 3px; font-weight: 500; }
