/* css/tickets-styles.css — Service Desk (tickets.html)
   Follows the reconciliation page's visual language: white cards, #e0e0e0
   borders, 6px radii, pill filters, small type. */

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.controls-left  { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.controls-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Reads as a view modifier next to the tabs, and goes amber when on so it is
   obvious the list now contains completed tickets. */
.td-closed-toggle {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 16px;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
}
.td-closed-toggle:hover { background: #f6f6f6; }
.td-closed-toggle.td-on {
    background: #fff4e5;
    border-color: #f0b357;
    color: #8a4b00;
    font-weight: 600;
}
.controls-right input[type="text"] {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 260px;
    font-size: 0.9rem;
}
.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* The global .btn sets a gradient background and hover transform. A pill filter
   needs explicit colors or it renders blank — same note as reconciliation.css. */
.filter-btn {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 16px;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-size: 0.85rem;
}
.filter-btn:hover { background: #f0f0f0; color: #333; transform: none; box-shadow: none; }
.filter-btn.active,
.filter-btn.active:hover { background: #0d6efd; border-color: #0d6efd; color: #fff; }

.td-inline-select { width: auto; min-width: 150px; padding: 7px 10px; font-size: 0.88rem; }
.td-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #555; }
.td-check input { margin: 0; }
.record-count { font-size: 0.85rem; color: #666; }

/* ── Loading / empty ───────────────────────────────────────────────────────── */
.loading { padding: 40px 20px; text-align: center; color: #666; }
.loading p { margin: 10px 0 0; font-size: 0.9rem; }
.spinner {
    width: 28px; height: 28px;
    margin: 0 auto;
    border: 3px solid #e0e0e0;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: td-spin 0.8s linear infinite;
}
@keyframes td-spin { to { transform: rotate(360deg); } }
.no-results { padding: 36px 20px; text-align: center; color: #777; font-size: 0.92rem; }

/* ── Ticket table ──────────────────────────────────────────────────────────── */
/* Wide content must scroll inside its own container, never the page body. */
.table-container { overflow-x: auto; }

.td-table { font-size: 0.88rem; }
.td-table tbody tr { cursor: pointer; }
.td-table td { vertical-align: top; }
.td-table .td-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.td-table .td-summary {
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-table .td-when { white-space: nowrap; color: #555; font-size: 0.83rem; }

.td-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    background: #eef1f5;
    color: #33415c;
    white-space: nowrap;
}

/* Age tiers: the CS team works the top of the list, so age has to be readable
   at a glance rather than parsed. */
.td-age {
    display: inline-block;
    min-width: 46px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}
.td-age-fresh { background: #e6f4ea; color: #14663b; }   /* under a day   */
.td-age-warm  { background: #fff4e5; color: #8a4b00; }   /* 1–3 days      */
.td-age-hot   { background: #fdecea; color: #a1160a; }    /* over 3 days   */
.td-age-none  { background: #f1f1f1; color: #777; }       /* no createDate */

.td-overdue { color: #a1160a; font-weight: 600; }

/* ── Detail drawer ─────────────────────────────────────────────────────────── */
.td-modal { max-width: 860px; width: 94%; }

.td-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 18px;
    padding: 14px 16px;
    margin-bottom: 16px;
    background: #fbfbfd;
    border: 1px solid #e8e8ee;
    border-radius: 6px;
}
.td-fact-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8a8a94;
    margin-bottom: 2px;
}
.td-fact-value { font-size: 0.9rem; color: #1a1a1a; word-break: break-word; }

.td-ask-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.td-ask-tyler { white-space: nowrap; }

.td-panel {
    padding: 16px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}
.td-panel h3 {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: #1a1a1a;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* Collapses to one column on narrow screens via the minmax floor. */
.td-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 14px;
}

/* Description and note bodies are plain text (often whole email threads):
   keep their line breaks, wrap long lines, and scroll rather than push the
   edit form off the screen. */
.td-description,
.td-note-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.87rem;
    line-height: 1.45;
    color: #222;
    max-height: 320px;
    overflow-y: auto;
}

.td-tyler-panel { border-color: #b9d3fb; background: #f5f9ff; }
.td-tyler-panel h3 { border-bottom-color: #d6e5fc; }

/* Each note is its own card: a header bar (who · when · visibility), the title,
   then the body. The coloured left edge says who wrote it at a glance —
   technician, client, or an automated/API user. */
.td-notes { display: flex; flex-direction: column; gap: 14px; }
.td-note {
    background: #fff;
    border: 1px solid #dfe3ea;
    border-left: 4px solid #0d6efd;            /* technician */
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    overflow: hidden;
}
.td-note-client { border-left-color: #f0a030; }  /* written by the client */
.td-note-system { border-left-color: #9aa3b2; }  /* API / automation      */
.td-note-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: #f6f8fb;
    border-bottom: 1px solid #e8ebf0;
}
.td-note-author { font-weight: 600; font-size: 0.84rem; color: #1a1a1a; }
.td-note-title  { padding: 10px 12px 0; font-weight: 600; font-size: 0.9rem; color: #1a1a1a; }
.td-note-meta   { font-size: 0.76rem; color: #6b7280; font-weight: 400; }
.td-note .td-note-body { padding: 6px 12px 12px; max-height: 260px; }

/* Rendered markdown (Tyler's analysis): normal wrapping, real headings/lists. */
.td-md { white-space: normal; }
.td-md .td-md-h { display: block; margin: 10px 0 4px; font-weight: 700; color: #1a1a1a; }
.td-md .td-md-h:first-child { margin-top: 0; }
.td-md ul, .td-md ol { margin: 4px 0 8px; padding-left: 22px; }
.td-md li { margin: 2px 0; }
.td-md p  { margin: 0 0 8px; }
.td-md code { background: #eef1f5; padding: 0 4px; border-radius: 3px; font-size: 0.82rem; }
.td-md hr { border: 0; border-top: 1px solid #d6e5fc; margin: 10px 0; }
.td-note-vis {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #eef1f5;
    color: #33415c;
    font-size: 0.7rem;
}

.td-additional { display: flex; flex-wrap: wrap; gap: 8px; }
.td-contact-chip {
    padding: 6px 10px;
    background: #f4f6f9;
    border: 1px solid #e2e6ec;
    border-radius: 6px;
    font-size: 0.83rem;
}
.td-contact-chip .td-chip-sub { display: block; color: #777; font-size: 0.76rem; }
.td-none { color: #888; font-size: 0.86rem; font-style: italic; }

.td-warning {
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #664d03;
    border-radius: 6px;
    font-size: 0.85rem;
}
.td-req { color: #a1160a; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.td-hint { font-size: 0.83rem; color: #666; }
.td-hint.td-ok  { color: #14663b; }
.td-hint.td-err { color: #a1160a; }

.button-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

@media (max-width: 640px) {
    .controls { flex-direction: column; align-items: stretch; }
    .controls-right input[type="text"] { min-width: 0; width: 100%; }
    .td-table .td-summary { max-width: 200px; }
}
