/* ============================================================================
   CollabCentral shared UI. All three top-level pages (sendMessage, monitorJobs,
   jobDetail) render on top of this stylesheet — every rule below is meant to
   be reusable across pages, and per-page tweaks stay in a small `<style>` at
   the top of each HTML file.
   ============================================================================ */

:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e5e7eb;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #dbeafe;
    --success: #15803d;
    --success-bg: #dcfce7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --warning: #a16207;
    --warning-bg: #fef9c3;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --content-max: 1100px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

.hidden { display: none !important; }

/* ------- Top nav ---------------------------------------------------------- */

.appHeader {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.appHeader__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0.6em 1.25em;
    display: flex;
    align-items: center;
    gap: 1em;
}

.appHeader__brand {
    display: flex;
    align-items: center;
    gap: 0.7em;
    min-width: 0;
}

.appHeader__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.appHeader__label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appHeader__nav {
    display: flex;
    gap: 0.4em;
    margin-left: 1em;
}

.appHeader__nav a {
    display: inline-block;
    padding: 0.4em 0.85em;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}
.appHeader__nav a:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}
.appHeader__nav a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
}

.appHeader__spacer { flex: 1; }

.appHeader__user {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 20ch;
}

/* ------- Page container / cards ------------------------------------------ */

.container {
    max-width: var(--content-max);
    margin: 1.5em auto;
    padding: 0 1.25em;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5em;
    margin-bottom: 1.5em;
}

.card h3 { margin-top: 0; }

.pageTitle {
    margin: 0 0 0.2em;
    font-size: 1.35rem;
    font-weight: 600;
}

.pageSubtitle {
    color: var(--text-muted);
    margin: 0 0 1.25em;
    font-size: 0.9rem;
}

/* ------- Panels (empty state) -------------------------------------------- */

.panel {
    max-width: 560px;
    margin: 4em auto;
    padding: 2.5em 2em;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.panel h2 {
    margin: 0 0 0.4em;
    font-size: 1.25rem;
    color: var(--text);
}
.panel p {
    margin: 0;
    color: var(--text-muted);
}

/* ------- Forms ----------------------------------------------------------- */

.field {
    margin-bottom: 1.1em;
}

.field > label {
    display: block;
    margin-bottom: 0.35em;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}

.field input[type="text"],
.field input[type="datetime-local"],
.field input[type="file"],
.field textarea,
.field select {
    width: 100%;
    padding: 0.55em 0.75em;
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input[type="text"]:focus,
.field input[type="datetime-local"]:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field .hint {
    display: block;
    margin-top: 0.3em;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1em;
}

/* File input tweak: browsers style these very differently; give it some room */
.field input[type="file"] {
    padding: 0.4em 0.6em;
    cursor: pointer;
}

/* EasyMDE overrides so it fits our neutral theme */
.EasyMDEContainer .CodeMirror {
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--card);
}
.EasyMDEContainer .editor-toolbar {
    border-color: var(--border-strong);
    background: var(--bg);
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
}
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
    background: var(--card);
    color: var(--text);
}

/* Image preview */
#file-ip-1-preview {
    display: block;
    max-width: 100%;
    max-height: 260px;
    border-radius: var(--radius-sm);
    margin-top: 0.4em;
    object-fit: contain;
}
#file-ip-1-preview:not([src]) { display: none; }

/* ------- Buttons --------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 0.55em 1.1em;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--bg); }
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    padding: 0.35em 0.7em;
}
.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.formActions {
    display: flex;
    gap: 0.6em;
    align-items: center;
    margin-top: 1em;
}

/* ------- Tables (DataTables-friendly) ------------------------------------ */

table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 0.92rem;
}
table.dataTable thead th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border) !important;
    padding: 0.7em 0.8em !important;
    text-align: left;
}
table.dataTable tbody td {
    padding: 0.7em 0.8em !important;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
    white-space: pre-wrap;
    word-wrap: break-word;
}
table.dataTable tbody tr:hover {
    background: var(--bg);
}
table.dataTable tbody tr:last-child td {
    border-bottom: none;
}
table.dataTable.no-footer { border-bottom: none; }

.dataTables_wrapper .dataTables_filter input {
    padding: 0.35em 0.6em;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
}

.dataTables_wrapper .dataTables_length select {
    padding: 0.3em 0.5em;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding-top: 0.75em;
}
.dataTables_wrapper .paginate_button {
    padding: 0.35em 0.7em !important;
    margin-left: 0.15em;
    border-radius: var(--radius-sm);
    color: var(--text-muted) !important;
    border: 1px solid transparent !important;
}
.dataTables_wrapper .paginate_button.current,
.dataTables_wrapper .paginate_button:hover {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
    border-color: var(--accent-soft) !important;
}

/* ------- Job-detail summary grid ----------------------------------------- */

.summary-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5em 1.5em;
    padding: 1.1em 1.25em;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 0 0 1.5em;
}
.summary-grid dt {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.88rem;
}
.summary-grid dd {
    margin: 0;
    color: var(--text);
    font-size: 0.92rem;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 1.5em 0 0.5em;
}

.message-preview {
    padding: 1em 1.25em;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.message-preview img { max-width: 100%; height: auto; }
.message-preview p:first-child { margin-top: 0; }
.message-preview p:last-child { margin-bottom: 0; }

/* ------- Pills ----------------------------------------------------------- */

.pill {
    display: inline-block;
    padding: 0.15em 0.7em;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.pill.ok      { background: var(--success-bg); color: var(--success); }
.pill.err     { background: var(--danger-bg);  color: var(--danger);  }
.pill.pending { background: var(--warning-bg); color: var(--warning); }

/* ------- Modal ----------------------------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(3px);
    z-index: 20;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 21;
    width: min(440px, 92vw);
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5em 1.75em;
    display: flex;
    flex-direction: column;
    gap: 0.6em;
}
.modal h3 { margin: 0; }
.modal p { color: var(--text-muted); margin: 0; }
.modal__close {
    align-self: flex-end;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2em 0.4em;
    border-radius: 999px;
}
.modal__close:hover { background: var(--bg); color: var(--text); }
.modal__actions {
    display: flex;
    gap: 0.6em;
    justify-content: flex-end;
    margin-top: 0.6em;
}

/* ------- Responsive ------------------------------------------------------ */

@media (max-width: 640px) {
    .field-row { grid-template-columns: 1fr; }
    .appHeader__inner { flex-wrap: wrap; }
    .appHeader__nav { margin-left: 0; }
    .container { padding: 0 1em; }
    .card { padding: 1.1em; }
}
