/* ═══════════════════════════════════════════════════════
   HiveDesk — Custom Styles
   ═══════════════════════════════════════════════════════ */

:root {
    --sidebar-bg:      #0f172a;
    --sidebar-text:    #94a3b8;
    --sidebar-hover:   #1e293b;
    --sidebar-active:  #3b82f6;
    --sidebar-width:   240px;
    --topbar-height:   56px;
    --body-bg:         #f1f5f9;
    --card-bg:         #ffffff;
    --card-border:     #e2e8f0;
    --card-shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Reset / Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: #1e293b;
    font-size: .9rem;
    min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────── */
#wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 200;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -.3px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-nav {
    padding: .75rem 0;
    flex: 1;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    color: var(--sidebar-text);
    font-size: .875rem;
    border-radius: 0;
    text-decoration: none;
    transition: background .15s, color .15s;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: var(--sidebar-hover);
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--sidebar-active);
    border-radius: 0 2px 2px 0;
}

.sidebar-nav .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: .7rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ── Main wrapper ─────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: .9rem;
}

/* ── Flash ────────────────────────────────────────────── */
.flash-container {
    padding: .75rem 1.25rem 0;
}

/* ── Page content ─────────────────────────────────────── */
.page-content {
    padding: 1.5rem 1.25rem;
    flex: 1;
}

/* ── Cards ────────────────────────────────────────────── */
.card {
    border: 1px solid var(--card-border);
    border-radius: .625rem;
    box-shadow: var(--card-shadow);
    background: var(--card-bg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: .875rem 1rem;
    font-weight: 600;
}

/* ── Avatar ───────────────────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    user-select: none;
    letter-spacing: -.5px;
}

/* ── Stat cards ───────────────────────────────────────── */
.stat-card {
    border-radius: .75rem;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: .625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-label { font-size: .8rem; color: #64748b; margin-bottom: .1rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: #0f172a; }

/* ── Kanban board ─────────────────────────────────────── */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 1rem;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-col {
    background: #f8fafc;
    border: 1px solid var(--card-border);
    border-radius: .625rem;
    min-height: 200px;
}

.kanban-col-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.kanban-col-body {
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 120px;
}

.kanban-card {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: .5rem;
    padding: .75rem;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    border-color: #cbd5e1;
    color: inherit;
}

.kanban-card.sortable-ghost {
    opacity: .4;
    border: 2px dashed #3b82f6;
}

.kanban-card-key {
    font-size: .7rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: .3rem;
    font-family: monospace;
}

.kanban-card-title {
    font-size: .82rem;
    font-weight: 500;
    line-height: 1.35;
    color: #1e293b;
    margin-bottom: .5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kanban-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Column accent bars */
.kanban-col[data-status="open"]        .kanban-col-header { border-top: 3px solid #94a3b8; }
.kanban-col[data-status="in_progress"] .kanban-col-header { border-top: 3px solid #f59e0b; }
.kanban-col[data-status="in_review"]   .kanban-col-header { border-top: 3px solid #8b5cf6; }
.kanban-col[data-status="done"]        .kanban-col-header { border-top: 3px solid #10b981; }

.col-count {
    background: #e2e8f0;
    color: #475569;
    border-radius: 99px;
    padding: .1rem .45rem;
    font-size: .7rem;
    font-weight: 700;
}

/* ── Ticket view ──────────────────────────────────────── */
.ticket-header {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: .625rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
}

.ticket-key {
    font-size: .8rem;
    font-weight: 700;
    color: #64748b;
    font-family: monospace;
    letter-spacing: .03em;
}

.ticket-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.ticket-description {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: .875rem;
    line-height: 1.65;
    color: #334155;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--card-border);
}

.detail-item:last-child { border-bottom: none; }

.detail-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #94a3b8;
}

.detail-value { font-size: .875rem; color: #1e293b; }

/* ── Comment ──────────────────────────────────────────── */
.comment-item {
    display: flex;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.comment-item:last-child { border-bottom: none; }

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

.comment-meta {
    font-size: .75rem;
    color: #94a3b8;
    margin-bottom: .3rem;
}

.comment-meta strong { color: #475569; }

.comment-text {
    font-size: .875rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: #334155;
}

/* ── Activity log ─────────────────────────────────────── */
.activity-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem 0;
    font-size: .8rem;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .65rem;
    color: #64748b;
}

/* ── Badges / Status ──────────────────────────────────── */
.status-badge { font-size: .75rem; }

/* ── Tables ───────────────────────────────────────────── */
.table-hover tbody tr:hover { background: #f8fafc; }

.table th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
}

/* ── Project cards ────────────────────────────────────── */
.project-card {
    border: 1px solid var(--card-border);
    border-radius: .75rem;
    background: #fff;
    padding: 1.25rem;
    transition: box-shadow .15s, border-color .15s;
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
    box-shadow: var(--card-shadow);
}

.project-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.1);
    border-color: #93c5fd;
    color: inherit;
}

.project-slug {
    font-family: monospace;
    font-size: .7rem;
    font-weight: 700;
    background: #eff6ff;
    color: #3b82f6;
    padding: .15rem .4rem;
    border-radius: .25rem;
}

/* ── Filters bar ──────────────────────────────────────── */
.filters-bar {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: .625rem;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
}

/* ── Inline edit selects ──────────────────────────────── */
.inline-select {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

.inline-select:focus {
    outline: none;
}

/* ── Page header ──────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .kanban-board {
        grid-template-columns: repeat(2, minmax(200px, 1fr));
    }
    .page-content {
        padding: 1rem .75rem;
    }
}

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

/* ── Sidebar overlay for mobile ───────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
}
.sidebar-overlay.show { display: block; }

/* ── Misc utilities ───────────────────────────────────── */
.text-muted-sm { font-size: .75rem; color: #94a3b8; }
.border-dashed  { border-style: dashed !important; }
.cursor-pointer { cursor: pointer; }
.no-data {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.no-data i { font-size: 3rem; margin-bottom: .75rem; display: block; }

/* ── Live Chat ────────────────────────────────────────── */
.chat-window {
    height: 320px;
    overflow-y: auto;
    padding: .75rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--card-border);
}

.chat-input-wrap {
    padding: .6rem .75rem;
}

.chat-input {
    resize: none;
    border-radius: .5rem;
    font-size: .85rem;
    line-height: 1.4;
    max-height: 80px;
    overflow-y: auto;
}

.chat-send-btn {
    flex-shrink: 0;
    height: 34px;
    width: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: .5rem;
}

/* Message rows */
.chat-msg { display: flex; gap: .4rem; max-width: 100%; }
.chat-msg-mine    { flex-direction: row-reverse; }
.chat-msg-theirs  { flex-direction: row; }

.chat-avatar { flex-shrink: 0; margin-top: .15rem; }

.chat-name {
    font-size: .68rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: .15rem;
    padding-left: .15rem;
}

/* Bubbles */
.chat-bubble {
    padding: .45rem .7rem;
    border-radius: .75rem;
    max-width: 220px;
    word-break: break-word;
}

.chat-bubble-mine {
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: .2rem;
}

.chat-bubble-theirs {
    background: #fff;
    border: 1px solid var(--card-border);
    color: #1e293b;
    border-bottom-left-radius: .2rem;
}

.chat-text { font-size: .82rem; line-height: 1.45; }

.chat-time {
    font-size: .65rem;
    margin-top: .2rem;
    opacity: .7;
    text-align: right;
}

.chat-bubble-theirs .chat-time { text-align: left; }

.chat-empty {
    text-align: center;
    color: #94a3b8;
    font-size: .78rem;
    margin: auto;
    padding: 1rem 0;
}

/* ── Auth pages ───────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

.auth-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-logo i { color: #3b82f6; }
