/* PlainDesk UI - built on Bootstrap 5. Brand tokens first, then components. */

:root {
  --pd-primary: #0F766E;          /* replaced by the brand color from Settings */
  --pd-primary-dark: color-mix(in srgb, var(--pd-primary) 82%, #000);
  --pd-primary-soft: color-mix(in srgb, var(--pd-primary) 10%, #fff);
  --pd-ink: #0F172A;
  --pd-muted: #64748B;
  --pd-line: #E2E8F0;
  --pd-bg: #F8FAFC;
  --pd-card: #FFFFFF;
  --pd-radius: 12px;
  --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Arabic", sans-serif;
  --bs-body-color: var(--pd-ink);
  --bs-body-bg: var(--pd-bg);
  --bs-border-color: var(--pd-line);
  --bs-link-color: var(--pd-primary);
  --bs-link-color-rgb: 15, 118, 110;
  --bs-link-hover-color: var(--pd-primary-dark);
  --bs-border-radius: 8px;
}

body { background: var(--pd-bg); font-size: 15px; }
a { color: var(--pd-primary); }
a:hover { color: var(--pd-primary-dark); }

/* Buttons and form focus use the brand color */
.btn-primary {
  --bs-btn-bg: var(--pd-primary); --bs-btn-border-color: var(--pd-primary);
  --bs-btn-hover-bg: var(--pd-primary-dark); --bs-btn-hover-border-color: var(--pd-primary-dark);
  --bs-btn-active-bg: var(--pd-primary-dark); --bs-btn-active-border-color: var(--pd-primary-dark);
  --bs-btn-disabled-bg: var(--pd-primary); --bs-btn-disabled-border-color: var(--pd-primary);
  font-weight: 600;
}
.btn-outline-primary {
  --bs-btn-color: var(--pd-primary); --bs-btn-border-color: var(--pd-primary);
  --bs-btn-hover-bg: var(--pd-primary); --bs-btn-hover-border-color: var(--pd-primary);
  --bs-btn-active-bg: var(--pd-primary-dark); --bs-btn-active-border-color: var(--pd-primary-dark);
}
.btn { border-radius: 8px; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--pd-line); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--pd-primary);
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--pd-primary) 20%, transparent);
}
.form-check-input:checked { background-color: var(--pd-primary); border-color: var(--pd-primary); }
.form-label { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form-text { color: var(--pd-muted); }

/* Top bar */
.pd-topbar { background: #fff; border-bottom: 1px solid var(--pd-line); }
.pd-topbar .navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--pd-ink); }
.pd-topbar .navbar-brand img { height: 32px; width: auto; }
.pd-topbar .nav-link { color: var(--pd-muted); font-weight: 600; border-radius: 8px; padding: 6px 12px !important; }
.pd-topbar .nav-link:hover { color: var(--pd-ink); background: var(--pd-bg); }
.pd-topbar .nav-link.active { color: var(--pd-primary); background: var(--pd-primary-soft); }
.pd-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--pd-primary); display: inline-flex; align-items: center; justify-content: center; }
.pd-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--pd-primary-soft); color: var(--pd-primary); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pd-avatar.staff { background: var(--pd-primary); color: #fff; }

/* Page */
.pd-main { padding: 28px 0 48px; }
.pd-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.pd-page-head h1 { font-size: 24px; font-weight: 700; margin: 0; }
.pd-sub { color: var(--pd-muted); margin: 4px 0 0; }
.pd-card { background: var(--pd-card); border: 1px solid var(--pd-line); border-radius: var(--pd-radius); }
.pd-card-body { padding: 20px; }
.pd-card-head { padding: 14px 20px; border-bottom: 1px solid var(--pd-line); font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pd-narrow { max-width: 440px; margin: 24px auto; }
.pd-medium { max-width: 760px; margin: 0 auto; }
.pd-footer { color: var(--pd-muted); font-size: 13px; padding: 24px 0; border-top: 1px solid var(--pd-line); }

/* Status and priority */
.pd-status, .pd-priority { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pd-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pd-status-open { color: #B45309; background: #FEF3C7; }
.pd-status-answered { color: #1D4ED8; background: #DBEAFE; }
.pd-status-closed { color: #475569; background: #F1F5F9; }
.pd-priority { padding: 2px 8px; border: 1px solid var(--pd-line); background: #fff; color: var(--pd-muted); }
.pd-priority-3 { color: #C2410C; border-color: #FED7AA; background: #FFF7ED; }
.pd-priority-4 { color: #B91C1C; border-color: #FECACA; background: #FEF2F2; }

/* Counter cards on the inbox */
.pd-counters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.pd-counter { display: block; background: #fff; border: 1px solid var(--pd-line); border-radius: var(--pd-radius); padding: 14px 16px; text-decoration: none; color: var(--pd-ink); transition: border-color .15s; }
.pd-counter:hover { border-color: var(--pd-primary); color: var(--pd-ink); }
.pd-counter.active { border-color: var(--pd-primary); box-shadow: inset 0 0 0 1px var(--pd-primary); }
.pd-counter .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.pd-counter .l { font-size: 13px; color: var(--pd-muted); font-weight: 600; }
@media (max-width: 767px) { .pd-counters { grid-template-columns: repeat(2, 1fr); } }

/* Ticket list */
.pd-list { list-style: none; margin: 0; padding: 0; }
.pd-list-item { display: flex; gap: 14px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--pd-line); text-decoration: none; color: inherit; }
.pd-list-item:last-child { border-bottom: 0; }
.pd-list-item:hover { background: var(--pd-bg); color: inherit; }
.pd-list-main { flex: 1; min-width: 0; }
.pd-list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--pd-ink); }
.pd-list-meta { font-size: 13px; color: var(--pd-muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.pd-list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.pd-num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--pd-muted); }
.pd-empty { text-align: center; padding: 48px 20px; color: var(--pd-muted); }
.pd-empty .pd-empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--pd-primary-soft); color: var(--pd-primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }

/* Filters */
.pd-filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--pd-line); background: #fff; border-radius: var(--pd-radius) var(--pd-radius) 0 0; }
.pd-filters .form-select, .pd-filters .form-control { width: auto; min-width: 140px; }
.pd-filters .pd-search { flex: 1; min-width: 180px; }
.pd-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.pd-tabs a { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--pd-muted); font-weight: 600; font-size: 14px; }
.pd-tabs a:hover { background: #fff; color: var(--pd-ink); }
.pd-tabs a.active { background: var(--pd-primary); color: #fff; }
.pd-tabs .c { opacity: .7; margin-inline-start: 4px; }

/* Conversation */
.pd-thread { display: flex; flex-direction: column; gap: 16px; }
.pd-msg { display: flex; gap: 12px; }
.pd-msg-body { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--pd-line); border-radius: var(--pd-radius); }
.pd-msg-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--pd-line); font-size: 13.5px; }
.pd-msg-head .who { font-weight: 700; }
.pd-msg-head .role { color: var(--pd-muted); font-weight: 500; margin-inline-start: 6px; }
.pd-msg-head time { color: var(--pd-muted); }
.pd-msg-text { padding: 14px 16px; overflow-wrap: anywhere; line-height: 1.6; }
.pd-msg.staff .pd-msg-body { border-color: color-mix(in srgb, var(--pd-primary) 30%, #fff); }
.pd-msg.staff .pd-msg-head { background: var(--pd-primary-soft); border-color: color-mix(in srgb, var(--pd-primary) 20%, #fff); border-radius: var(--pd-radius) var(--pd-radius) 0 0; }
.pd-msg.note .pd-msg-body { background: #FFFBEB; border-color: #FDE68A; border-style: dashed; }
.pd-msg.note .pd-msg-head { background: transparent; border-color: #FDE68A; }
.pd-note-tag { font-size: 11.5px; font-weight: 700; color: #92400E; background: #FEF3C7; padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px; }
.pd-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; }
.pd-file { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--pd-line); border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--pd-ink); background: #fff; max-width: 100%; }
.pd-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-file small { color: var(--pd-muted); }
.pd-file:hover { border-color: var(--pd-primary); }

/* Reply box */
.pd-reply { margin-top: 20px; }
.pd-reply textarea { min-height: 140px; border: 0; resize: vertical; padding: 14px 16px; }
.pd-reply textarea:focus { box-shadow: none; }
.pd-reply-tabs { display: flex; border-bottom: 1px solid var(--pd-line); }
.pd-reply-tabs label { padding: 10px 16px; font-weight: 600; font-size: 14px; color: var(--pd-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pd-reply-tabs input { display: none; }
.pd-reply-tabs input:checked + span { color: var(--pd-ink); }
.pd-reply-tabs label:has(input:checked) { border-bottom-color: var(--pd-primary); color: var(--pd-ink); }
.pd-reply.is-note .pd-card { background: #FFFBEB; border-color: #FDE68A; }
.pd-reply.is-note textarea { background: #FFFBEB; }
.pd-reply-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--pd-line); }
.pd-attach { position: relative; }
.pd-attach input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pd-attach-names { font-size: 13px; color: var(--pd-muted); }

/* Sidebar details */
.pd-dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.pd-dl dt { color: var(--pd-muted); font-weight: 500; }
.pd-dl dd { margin: 0; text-align: end; overflow-wrap: anywhere; }
@media (min-width: 992px) { .pd-sticky { position: sticky; top: 20px; } }

/* Auth pages */
.pd-auth-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.pd-auth-logo img { height: 48px; }
.pd-hero { text-align: center; padding: 48px 16px 24px; }
.pd-hero h1 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.pd-hero p { color: var(--pd-muted); font-size: 17px; max-width: 520px; margin: 8px auto 24px; }
.pd-choice { display: block; height: 100%; padding: 24px; text-decoration: none; color: var(--pd-ink); }
.pd-choice:hover { border-color: var(--pd-primary); color: var(--pd-ink); }
.pd-choice .pd-empty-icon { margin-bottom: 12px; }
.pd-choice h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.pd-choice p { color: var(--pd-muted); margin: 0; font-size: 14px; }

/* Tables (admin) */
.pd-table { margin: 0; }
.pd-table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--pd-muted); font-weight: 600; background: var(--pd-bg); border-bottom-width: 1px; white-space: nowrap; }
.pd-table td, .pd-table th { padding: 12px 16px; vertical-align: middle; }
.pd-settings-nav .nav-link { color: var(--pd-muted); font-weight: 600; border-radius: 8px; }
.pd-settings-nav .nav-link.active { background: var(--pd-primary-soft); color: var(--pd-primary); }
.pd-progress { height: 6px; background: var(--pd-line); border-radius: 99px; overflow: hidden; min-width: 80px; }
.pd-progress > div { height: 100%; background: var(--pd-primary); }

.alert { border-radius: 10px; }
.pd-icon { width: 18px; height: 18px; flex-shrink: 0; }
.pd-icon-lg { width: 26px; height: 26px; }

/* RTL details */
[dir=rtl] .pd-dl dd { text-align: start; }

/* Demo mode */
.pd-demo-bar { background: var(--pd-ink); color: #E2E8F0; font-size: 13px; text-align: center; padding: 6px 12px; }
.pd-demo-bar a { color: #fff; font-weight: 600; margin-inline-start: 6px; }
.pd-demo-login { background: var(--pd-primary-soft); border-radius: 10px; padding: 14px; }
[dir=rtl] .pd-flip-rtl { transform: scaleX(-1); }
[dir=rtl] .pd-list-title[dir=auto] { text-align: right; }

/* API page and tags */
.pd-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.pd-pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--pd-bg); border: 1px solid var(--pd-line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; text-align: left; }
.pd-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pd-tag { font-size: 11.5px; font-weight: 600; color: var(--pd-primary); background: var(--pd-primary-soft); padding: 1px 8px; border-radius: 999px; text-decoration: none; white-space: nowrap; }
a.pd-tag:hover { color: var(--pd-primary); text-decoration: underline; }
