/* FCM Ticket System - enterprise UI theme */

:root {
    --fcm-bg: #f1f5f9;
    --fcm-surface: #ffffff;
    --fcm-border: #e2e8f0;
    --fcm-text: #0f172a;
    --fcm-muted: #64748b;
    --fcm-primary: #4f46e5;
    --fcm-primary-dark: #4338ca;
    --fcm-primary-soft: #eef2ff;
    --fcm-sidebar: #0f172a;
    --fcm-sidebar-hover: #1e293b;
    --fcm-sidebar-text: #cbd5e1;
    --fcm-radius: 12px;
    --fcm-shadow: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
    --fcm-shadow-lg: 0 10px 25px -5px rgb(15 23 42 / 0.1), 0 8px 10px -6px rgb(15 23 42 / 0.05);
}

* { box-sizing: border-box; }

body {
    background: var(--fcm-bg);
    color: var(--fcm-text);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    margin: 0;
    min-height: 100vh;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

/* ---------------------------------------------------------------- layout shell */

.fcm-shell { display: flex; min-height: 100vh; }

.fcm-sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--fcm-sidebar);
    color: var(--fcm-sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.fcm-sidebar::-webkit-scrollbar { width: 6px; }
.fcm-sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.fcm-brand {
    padding: 18px 20px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fcm-brand-mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 15px;
    flex-shrink: 0;
}

.fcm-brand-text { line-height: 1.15; min-width: 0; }
.fcm-brand-text strong { color: #fff; font-size: 15px; display: block; }
.fcm-brand-text span { font-size: 11px; color: #64748b; }

.fcm-nav { padding: 10px 0 24px; flex: 1; }

.fcm-nav-group {
    padding: 14px 20px 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    font-weight: 700;
}

.fcm-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 20px;
    color: var(--fcm-sidebar-text);
    font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s;
}

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

.fcm-nav-link.active {
    background: var(--fcm-sidebar-hover);
    color: #fff;
    border-left-color: #6366f1;
    font-weight: 600;
}

.fcm-nav-link i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.fcm-nav-link .badge { margin-left: auto; font-size: 10px; font-weight: 700; }

.fcm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.fcm-topbar {
    background: var(--fcm-surface);
    border-bottom: 1px solid var(--fcm-border);
    padding: 0 22px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.fcm-search { flex: 1; max-width: 460px; position: relative; }
.fcm-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fcm-muted); font-size: 14px; }
.fcm-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--fcm-border);
    border-radius: 8px;
    background: #f8fafc;
    font-size: 13.5px;
}
.fcm-search input:focus { outline: none; border-color: var(--fcm-primary); background: #fff; box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1); }

.fcm-content { padding: 22px; flex: 1; }

/* ---------------------------------------------------------------- avatars */

.fcm-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-grid; place-items: center;
    color: #fff; font-weight: 600; font-size: 11.5px;
    flex-shrink: 0;
    letter-spacing: .3px;
}
.fcm-avatar.sm { width: 25px; height: 25px; font-size: 9.5px; }
.fcm-avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.fcm-avatar.xl { width: 78px; height: 78px; font-size: 27px; }

.fcm-user-chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.fcm-user-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- cards */

.fcm-card {
    background: var(--fcm-surface);
    border: 1px solid var(--fcm-border);
    border-radius: var(--fcm-radius);
    box-shadow: var(--fcm-shadow);
}

.fcm-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--fcm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.fcm-card-header h2, .fcm-card-header h3 {
    margin: 0; font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px;
}

.fcm-card-body { padding: 18px; }
.fcm-card-body.tight { padding: 0; }

/* ---------------------------------------------------------------- stat tiles */

.fcm-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }

.fcm-stat {
    background: var(--fcm-surface);
    border: 1px solid var(--fcm-border);
    border-radius: var(--fcm-radius);
    padding: 15px 16px;
    box-shadow: var(--fcm-shadow);
    display: block;
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: transform .12s, box-shadow .12s;
}

a.fcm-stat:hover { transform: translateY(-2px); box-shadow: var(--fcm-shadow-lg); color: inherit; }

.fcm-stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--tile, var(--fcm-primary));
}

.fcm-stat-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--fcm-muted); font-weight: 700; margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
}
.fcm-stat-value { font-size: 27px; font-weight: 700; line-height: 1; color: var(--fcm-text); }
.fcm-stat-hint { font-size: 11.5px; color: var(--fcm-muted); margin-top: 6px; }

/* ---------------------------------------------------------------- badges */

.fcm-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.5;
}
.fcm-badge i { font-size: 10.5px; }
.fcm-badge.square { border-radius: 6px; }

.fcm-queue-pos {
    display: inline-grid; place-items: center;
    min-width: 26px; height: 26px; padding: 0 6px;
    border-radius: 7px;
    background: var(--fcm-primary-soft);
    color: var(--fcm-primary-dark);
    font-weight: 700; font-size: 12px;
}

/* ---------------------------------------------------------------- tables */

.fcm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.fcm-table thead th {
    text-align: left;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--fcm-border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--fcm-muted);
    font-weight: 700;
    white-space: nowrap;
}
.fcm-table tbody td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.fcm-table tbody tr:last-child td { border-bottom: none; }
.fcm-table tbody tr:hover { background: #f8fafc; }
.fcm-table .nowrap { white-space: nowrap; }
.fcm-table-wrap { overflow-x: auto; }

.fcm-ticket-link { font-weight: 600; color: var(--fcm-primary-dark); font-family: "Consolas", monospace; font-size: 12.5px; }
.fcm-ticket-title { display: block; color: var(--fcm-text); font-weight: 500; margin-top: 2px; }
.fcm-ticket-title:hover { color: var(--fcm-primary); }

tr.is-overdue { background: #fef2f2 !important; }
tr.is-overdue:hover { background: #fee2e2 !important; }
tr.is-paused { background: #fffbeb !important; }
tr.is-paused:hover { background: #fef3c7 !important; }

/* ---------------------------------------------------------------- timeline */

.fcm-timeline { position: relative; padding-left: 30px; }
.fcm-timeline::before {
    content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px;
    width: 2px; background: var(--fcm-border);
}
.fcm-timeline-item { position: relative; padding-bottom: 18px; }
.fcm-timeline-item:last-child { padding-bottom: 0; }
.fcm-timeline-dot {
    position: absolute; left: -30px; top: 1px;
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-size: 10.5px;
    border: 3px solid var(--fcm-surface);
    box-shadow: 0 0 0 1px var(--fcm-border);
}
.fcm-timeline-body { font-size: 13.5px; }
.fcm-timeline-meta { font-size: 11.5px; color: var(--fcm-muted); margin-top: 3px; }
.fcm-timeline-change {
    margin-top: 6px; font-size: 12.5px;
    background: #f8fafc; border: 1px solid var(--fcm-border);
    border-radius: 8px; padding: 6px 10px;
}
.fcm-timeline-change del { color: #b91c1c; text-decoration: line-through; }
.fcm-timeline-change ins { color: #047857; text-decoration: none; font-weight: 600; }

/* ---------------------------------------------------------------- comments */

.fcm-comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.fcm-comment:last-child { border-bottom: none; }
.fcm-comment-bubble {
    flex: 1; min-width: 0;
    background: #f8fafc;
    border: 1px solid var(--fcm-border);
    border-radius: 10px;
    padding: 11px 14px;
}
.fcm-comment.internal .fcm-comment-bubble { background: #fffbeb; border-color: #fde68a; }
.fcm-comment.request .fcm-comment-bubble { background: #eff6ff; border-color: #bfdbfe; }
.fcm-comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.fcm-comment-head strong { font-size: 13px; }
.fcm-comment-body { font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }

/* ---------------------------------------------------------------- attachments */

.fcm-attachments { display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.fcm-attachment {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--fcm-border);
    border-radius: 9px;
    background: var(--fcm-surface);
    color: inherit;
    transition: border-color .12s, box-shadow .12s;
    min-width: 0;
}
.fcm-attachment:hover { border-color: var(--fcm-primary); box-shadow: var(--fcm-shadow); color: inherit; }
.fcm-attachment i { font-size: 20px; color: var(--fcm-primary); flex-shrink: 0; }
.fcm-attachment-info { min-width: 0; flex: 1; }
.fcm-attachment-info strong { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcm-attachment-info small { color: var(--fcm-muted); font-size: 11px; }
.fcm-attachment-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }

/* ---------------------------------------------------------------- detail panel */

.fcm-detail-grid { display: grid; gap: 0 22px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.fcm-field { padding: 9px 0; border-bottom: 1px solid #f1f5f9; }
.fcm-field:last-child { border-bottom: none; }
.fcm-field-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--fcm-muted); font-weight: 700; margin-bottom: 4px;
}
.fcm-field-value { font-size: 13.5px; font-weight: 500; }

/* ---------------------------------------------------------------- SLA split bar */

.fcm-sla-bar {
    display: flex; height: 26px; border-radius: 8px; overflow: hidden;
    border: 1px solid var(--fcm-border); background: #f1f5f9;
}
.fcm-sla-seg {
    display: grid; place-items: center;
    color: #fff; font-size: 10.5px; font-weight: 700;
    min-width: 0; overflow: hidden; white-space: nowrap;
}
.fcm-sla-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 11px; font-size: 12.5px; }
.fcm-sla-legend > div { display: flex; align-items: center; gap: 7px; }
.fcm-legend-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

/* ---------------------------------------------------------------- progress */

.fcm-progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.fcm-progress-bar { height: 100%; border-radius: 4px; transition: width .3s; }

/* ---------------------------------------------------------------- charts */

.fcm-bar-row { display: flex; align-items: center; gap: 11px; padding: 6px 0; font-size: 13px; }
.fcm-bar-label { width: 145px; flex-shrink: 0; color: var(--fcm-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcm-bar-track { flex: 1; height: 20px; background: #f1f5f9; border-radius: 5px; overflow: hidden; min-width: 40px; }
.fcm-bar-fill { height: 100%; border-radius: 5px; min-width: 3px; transition: width .3s; }
.fcm-bar-value { width: 58px; text-align: right; font-weight: 700; flex-shrink: 0; font-size: 12.5px; }

/* ---------------------------------------------------------------- queue board */

.fcm-queue-row { cursor: default; }
.fcm-queue-row.draggable { cursor: grab; }
.fcm-queue-row.draggable:active { cursor: grabbing; }
.fcm-queue-row.dragging { opacity: .4; background: var(--fcm-primary-soft) !important; }
.fcm-queue-row.drag-over td { border-top: 2px solid var(--fcm-primary); }
.fcm-drag-handle { color: #cbd5e1; cursor: grab; font-size: 15px; }
.fcm-drag-handle:hover { color: var(--fcm-primary); }

.fcm-priority-band {
    padding: 8px 14px; font-weight: 700; font-size: 11.5px;
    text-transform: uppercase; letter-spacing: .05em;
    border-left: 4px solid;
}

/* ---------------------------------------------------------------- notifications */

.fcm-notif-btn { position: relative; background: none; border: none; font-size: 18px; color: var(--fcm-muted); padding: 6px 8px; }
.fcm-notif-btn:hover { color: var(--fcm-primary); }
.fcm-notif-dot {
    position: absolute; top: 2px; right: 2px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: #dc2626; color: #fff;
    font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
.fcm-notif-list { width: 370px; max-height: 440px; overflow-y: auto; padding: 0; }
.fcm-notif-item { display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid #f1f5f9; color: inherit; }
.fcm-notif-item:hover { background: #f8fafc; color: inherit; }
.fcm-notif-item.unread { background: var(--fcm-primary-soft); }
.fcm-notif-item.unread:hover { background: #e0e7ff; }
.fcm-notif-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-size: 14px; }
.fcm-notif-text { min-width: 0; flex: 1; }
.fcm-notif-text strong { display: block; font-size: 12.5px; font-weight: 600; }
.fcm-notif-text p { margin: 2px 0 0; font-size: 12px; color: var(--fcm-muted); line-height: 1.4; }
.fcm-notif-text small { font-size: 10.5px; color: #94a3b8; }

/* ---------------------------------------------------------------- filters */

.fcm-filter-bar {
    display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-end;
    padding: 14px 18px; border-bottom: 1px solid var(--fcm-border); background: #f8fafc;
}
.fcm-filter-field { display: flex; flex-direction: column; gap: 4px; }
.fcm-filter-field label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--fcm-muted); font-weight: 700; }
.fcm-filter-field select, .fcm-filter-field input {
    border: 1px solid var(--fcm-border); border-radius: 7px; padding: 6px 9px; font-size: 13px; background: #fff; min-width: 130px;
}

.fcm-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.fcm-chip {
    padding: 5px 12px; border-radius: 18px; font-size: 12.5px; font-weight: 600;
    border: 1px solid var(--fcm-border); background: #fff; color: var(--fcm-muted);
}
.fcm-chip:hover { border-color: var(--fcm-primary); color: var(--fcm-primary); }
.fcm-chip.active { background: var(--fcm-primary); border-color: var(--fcm-primary); color: #fff; }

/* ---------------------------------------------------------------- misc */

.fcm-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.fcm-page-head h1 { font-size: 21px; font-weight: 700; margin: 0 0 3px; }
.fcm-page-head p { margin: 0; color: var(--fcm-muted); font-size: 13.5px; max-width: 720px; }

.fcm-empty { text-align: center; padding: 42px 20px; color: var(--fcm-muted); }
.fcm-empty i { font-size: 38px; opacity: .3; display: block; margin-bottom: 11px; }
.fcm-empty p { margin: 0; font-size: 13.5px; }

.fcm-banner {
    border-radius: 10px; padding: 13px 16px; margin-bottom: 16px;
    display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px;
    border: 1px solid;
}
.fcm-banner i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.fcm-banner strong { display: block; margin-bottom: 2px; }
.fcm-banner.danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.fcm-banner.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.fcm-banner.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.fcm-banner.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.fcm-section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--fcm-muted); font-weight: 700; margin: 0 0 11px;
    display: flex; align-items: center; gap: 7px;
}

.text-mono { font-family: "Consolas", "Courier New", monospace; }

.btn { font-size: 13.5px; border-radius: 8px; font-weight: 500; }
.btn-sm { font-size: 12.5px; padding: 4px 10px; }
.btn-primary { background: var(--fcm-primary); border-color: var(--fcm-primary); }
.btn-primary:hover { background: var(--fcm-primary-dark); border-color: var(--fcm-primary-dark); }

.form-label { font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.form-control, .form-select { font-size: 13.5px; border-radius: 8px; border-color: var(--fcm-border); }
.form-control:focus, .form-select:focus { border-color: var(--fcm-primary); box-shadow: 0 0 0 3px rgb(79 70 229 / .1); }
.form-text { font-size: 11.5px; }

.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-content { border-radius: var(--fcm-radius); border: none; }
.modal-header { border-bottom: 1px solid var(--fcm-border); padding: 15px 18px; }
.modal-body { padding: 18px; }
.modal-footer { border-top: 1px solid var(--fcm-border); padding: 13px 18px; }

.nav-tabs { border-bottom: 1px solid var(--fcm-border); gap: 2px; }
.nav-tabs .nav-link {
    border: none; border-bottom: 2px solid transparent;
    color: var(--fcm-muted); font-size: 13.5px; font-weight: 600; padding: 9px 14px;
}
.nav-tabs .nav-link:hover { border-bottom-color: #cbd5e1; color: var(--fcm-text); }
.nav-tabs .nav-link.active { color: var(--fcm-primary); border-bottom-color: var(--fcm-primary); background: none; }

/* ---------------------------------------------------------------- login */

.fcm-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #312e81 50%, #4c1d95 100%);
    padding: 20px;
}
.fcm-login-card {
    width: 100%; max-width: 410px;
    background: #fff; border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / .35);
    padding: 34px;
}
.fcm-login-brand { text-align: center; margin-bottom: 26px; }
.fcm-login-brand .fcm-brand-mark { width: 54px; height: 54px; font-size: 20px; margin: 0 auto 13px; border-radius: 14px; }
.fcm-login-brand h1 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.fcm-login-brand p { color: var(--fcm-muted); font-size: 13px; margin: 0; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 992px) {
    .fcm-sidebar { position: fixed; left: -250px; z-index: 1050; transition: left .22s; }
    .fcm-sidebar.open { left: 0; box-shadow: var(--fcm-shadow-lg); }
    .fcm-sidebar-backdrop { position: fixed; inset: 0; background: rgb(15 23 42 / .5); z-index: 1040; }
    .fcm-bar-label { width: 105px; }
    .fcm-search { max-width: none; }
}

@media (max-width: 576px) {
    .fcm-content { padding: 14px; }
    .fcm-stats { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
    .fcm-stat-value { font-size: 23px; }
}

@media print {
    .fcm-sidebar, .fcm-topbar, .btn, .fcm-filter-bar { display: none !important; }
    .fcm-content { padding: 0; }
    .fcm-card { box-shadow: none; border-color: #cbd5e1; page-break-inside: avoid; }
}
