:root {
    --accent: #110f7c;
    --accent-hover: #0d0b5e;
    --border: #d8d8e2;
    --text: #1c1c28;
    --muted: #63637a;
    --bg-subtle: #f6f6fb;
    --danger: #b3261e;
    --success: #1e7a3a;
    --private: #fff3cd;
    --private-text: #8a6300;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: #fff;
    margin: 0;
    padding: 24px 16px 64px;
    line-height: 1.5;
}

.container {
    max-width: 880px;
    margin: 0 auto;
}

.container-wide {
    max-width: 1400px;
    /* Roughly matches the look of the page at 80% browser zoom, scoped to
       this page (the dense case list) rather than the whole app. */
    font-size: 0.8em;
    /* Pulls content up closer to the top of the page — body's own 24px
       top padding is shared with every other page, so this trims it back
       just here rather than changing it globally. Title/search/filters/
       log-out are now one row instead of three stacked blocks, so there's
       room to pull up further than before. */
    margin-top: -20px;
}

.case-list td,
.case-list th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.case-list th.sortable {
    cursor: pointer;
    user-select: none;
}

.case-list th.sortable:hover {
    background: rgba(0, 0, 0, 0.05);
}

.case-list th.sortable.sorted {
    font-weight: 700;
}

.sort-indicator {
    font-size: 0.75em;
}

a {
    color: var(--accent);
}

a:hover {
    color: var(--accent-hover);
}

h1, h2, h3 {
    color: var(--accent);
    line-height: 1.25;
}

h1 {
    font-size: 1.6em;
}

h2 {
    font-size: 1.25em;
    margin-top: 2.2em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3em;
}

h3 {
    font-size: 1.05em;
    margin-bottom: 0.4em;
}

.filter-banner {
    background: #fff8e1;
    border: 1px solid #f0d98c;
    border-radius: 4px;
    padding: 8px 14px;
    margin-bottom: 14px;
    font-size: 0.95em;
}

.filter-banner a {
    font-weight: 600;
}

/* Desktop-only by design (per user) — title, search, actions, filters and
   the logged-in/log-out text all share one row, no wrap fallback needed. */
.list-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    margin-bottom: 14px;
}

.list-header-row h1 {
    margin: 0;
    font-size: 1.5em;
    white-space: nowrap;
}

.list-header-row .topbar-user {
    margin-left: auto;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    white-space: nowrap;
    font-size: 0.85em;
    color: var(--muted);
}

.list-header-row input[type="text"] {
    flex: 0 0 300px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.95em;
}

.list-header-row a.btn,
.list-header-row .btn-secondary {
    flex: 0 0 auto;
    white-space: nowrap;
}

.list-header-row .list-filter-select {
    width: auto;
    flex: 0 0 150px;
    padding: 8px 10px;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
}

th {
    background: var(--bg-subtle);
    color: var(--accent);
}

tr:hover td {
    background: var(--bg-subtle);
}

a.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 20px;
    border-radius: 5px;
    font-size: 0.95em;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.2;
}

a.btn:hover {
    background: var(--accent-hover);
    color: #fff;
}

.delete-case-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 500;
}

.trash-fab-btn {
    width: 48px;
    height: 48px;
    padding: 11px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trash-fab-btn:hover {
    background: var(--accent-hover);
}

.trash-fab-btn img {
    width: 100%;
    height: 100%;
    /* Forces the icon white regardless of its own source color, to read
       clearly against the dark button background. */
    filter: brightness(0) invert(1);
}

.list-count {
    color: var(--muted);
    font-size: 0.9em;
    white-space: nowrap;
}

.list-count strong {
    color: var(--text);
}

/* Row colors track waiting_status, same idea as the old gbp-admin tool:
   two shades per status so alternating rows within the same status are
   still visually distinguishable, not just a flat block of one color.
   Hover uses `background: inherit` (pulling the row's own color) plus a
   brightness filter, overriding the generic `tr:hover td` rule elsewhere
   in this file which would otherwise paint every hovered cell the same
   flat --bg-subtle regardless of status. */
.case-list tbody tr.row-waiting-me-0    { background: #c1f4e1; }
.case-list tbody tr.row-waiting-me-1    { background: #d6f8ec; }
.case-list tbody tr.row-waiting-google-0 { background: #cbdbf7; }
.case-list tbody tr.row-waiting-google-1 { background: #e2edff; }
.case-list tbody tr.row-waiting-client-0 { background: #c4ecff; }
.case-list tbody tr.row-waiting-client-1 { background: #d9f3ff; }
.case-list tbody tr.row-new-0 { background: #fff3c4; }
.case-list tbody tr.row-new-1 { background: #fff8de; }
.case-list tbody tr.row-inactive-0 { background: #d8d0f0; }
.case-list tbody tr.row-inactive-1 { background: #e8e3f5; }
.case-list tbody tr.row-resolved-0 { background: #eeeeee; }
.case-list tbody tr.row-resolved-1 { background: #f8f8f8; }
.case-list tbody tr.row-other-0 { background: #ffffff; }
.case-list tbody tr.row-other-1 { background: #f7f7fb; }

.case-list tbody tr:hover {
    filter: brightness(0.94);
}

.case-list tbody tr:hover td {
    background: inherit;
}

.list-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
}

.list-page-indicator {
    color: var(--muted);
    font-size: 0.9em;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px 8px;
    margin: 0 0 22px;
}

legend {
    color: var(--accent);
    font-weight: 600;
    padding: 0 8px;
}

.field {
    margin-bottom: 14px;
    flex: 1 1 220px;
}

.field-narrow {
    flex: 0 1 160px;
}

.field-xs {
    flex: 0 0 90px;
}

.gbpa-id-link {
    display: block;
    margin-top: 4px;
    font-size: 0.78em;
    line-height: 1.3;
}

.agency-new-input {
    display: block;
    margin-top: 6px;
}

.hidden {
    display: none;
}

.field-warning {
    color: #b7791f;
    font-size: 0.8em;
    margin: 4px 0 0;
}

.contact-name-wrap {
    display: inline;
    white-space: nowrap;
}

.copy-email-btn {
    display: inline-block;
    vertical-align: super;
    width: 12px;
    height: 12px;
    margin-left: 3px;
    padding: 0;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
}

.copy-email-btn svg {
    width: 100%;
    height: 100%;
    display: block;
}

.copy-email-btn:hover {
    color: #555;
}

.copy-email-btn.copied {
    color: #2e7d32;
}

.field label {
    display: block;
    font-weight: 500;
    font-size: 0.92em;
    margin-bottom: 4px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.95em;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(17, 15, 124, 0.15);
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-field input {
    width: auto;
}

button,
input[type="submit"] {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 20px;
    border-radius: 5px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
    background: var(--accent-hover);
}

.danger-btn {
    background: #8f1111;
}

.danger-btn:hover {
    background: #6e0d0d;
}

details > summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    padding: 10px 0;
}

details {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 20px;
    margin-bottom: 22px;
}

.upload-type-group {
    margin-bottom: 16px;
}

.upload-type-group > .type-label {
    font-weight: 500;
    font-size: 0.92em;
    margin-bottom: 6px;
    display: block;
}

.upload-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.upload-slot .slot-number {
    color: var(--muted);
    font-size: 0.85em;
    min-width: 1.5em;
}

.alert {
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.95em;
}

.alert-error {
    background: #fbeceb;
    color: var(--danger);
    border: 1px solid #f0c9c6;
}

.alert-success {
    background: #eaf6ee;
    color: var(--success);
    border: 1px solid #c8e6d0;
}

.message-card {
    border: 1px solid #d5d5e0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 10px 14px;
    background: #f5f5f8;
}

.message-card.staff {
    background: #fbfbfc;
    margin-left: 2.5em;
}

.message-card.private {
    background: var(--private);
    border-color: #f0d78c;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.88em;
    color: var(--muted);
    margin-bottom: 20px;
}

.message-meta .private-label {
    color: var(--private-text);
    font-weight: 600;
}

.sender-block {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
}

.message-meta .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.sender-name {
    font-size: 1.2em;
    color: var(--text);
}

.message-body {
    line-height: 1.35;
}

.message-body p {
    margin: 0 0 0.7em;
}

.message-body p:last-child {
    margin-bottom: 0;
}

.attachment-staging,
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.attachment-staging-item {
    position: relative;
    width: 72px;
    height: 72px;
}

.attachment-staging-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.attachment-staging-remove {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 20px;
    height: 20px;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9em;
}

.attachment-cap-message {
    margin: 6px 0;
}

.attachment-thumb-link {
    display: block;
    width: 88px;
    height: 88px;
}

.attachment-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: zoom-in;
}

.attachment-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    cursor: zoom-out;
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 100%;
    max-height: 100%;
    cursor: default;
}

.lightbox-content img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    border-radius: 4px;
    display: block;
}

.lightbox-actions {
    flex-shrink: 0;
}

.lightbox-actions .btn {
    padding: 8px 18px;
}

.edit-link {
    font-size: 0.9em;
    white-space: nowrap;
}

.button-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.btn-secondary {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-private-note {
    background: var(--private);
    color: var(--private-text);
    border: 1px solid #f0d78c;
}

.btn-private-note:hover {
    background: #f5e6ad;
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.load-earlier-btn {
    display: block;
    margin: 6px auto 0;
}

.upload-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.upload-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95em;
}

.upload-list li:last-child {
    border-bottom: none;
}

.muted {
    color: var(--muted);
    font-size: 0.9em;
}
