/* =============================================================
   CentralDesk Shared Stylesheet
   Location: centraldesk/css/centraldesk.css
   Fonts: Share Tech (headings), Manrope (body)
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Gelasio:ital,wght@0,400;0,600;1,400;1,600&family=Manrope:wght@300;400;500;600;700&display=swap');

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ── */
:root {
  --navy:    #080f1a;
  --ink:     #0d1a2e;
  --blue:    #1a3a5c;
  --sky:     #3d7ebf;
  --gold:    #c9973a;
  --gold-lt: #e8b86d;
  --cream:   #fafaf7;
  --bg:      #f0f4f8;
  --white:   #ffffff;
  --text:    #1a2e45;
  --muted:   #5a7a9a;
  --border:  #d0dde8;

  --sidebar: 240px;
  --radius:  10px;

  /* Status colours */
  --open:            #1a3a5c; --open-bg:            #e6f0fb;
  --in-progress:     #7a4a00; --in-progress-bg:     #fef3e2;
  --waiting:         #5a3a8a; --waiting-bg:         #f3eefe;
  --resolved:        #1a6a3a; --resolved-bg:        #e6f7ee;
  --closed:          #4a4a4a; --closed-bg:          #f0f0f0;

  /* Priority colours */
  --low:    #3a6a4a; --low-bg:    #eaf5ee;
  --medium: #5a5a00; --medium-bg: #fafae0;
  --high:   #8a3a00; --high-bg:   #fef0e6;
  --urgent: #8a0000; --urgent-bg: #fee6e6;
}

/* ── Base typography ── */
body {
  font-family: 'Manrope', sans-serif;
  color: var(--text);
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6,
.wordmark,
.topbar-title,
.sidebar-logo .wordmark,
.page-title,
.auth-heading,
.picker-heading {
  font-family: 'Gelasio', serif;
  font-weight: 400; /* Share Tech is single-weight */
}

/* ── App shell ── */
body.app-layout {
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: auto 1fr;
}

/* ── Sidebar ── */
.sidebar {
  grid-row: 1 / 3;
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
  display: block;
}
.sidebar-logo .wordmark {
  font-family: 'Gelasio', serif;
  font-size: 20px;
  color: #fff;
}
.sidebar-logo .wordmark span { color: var(--gold); }
.sidebar-logo .portal-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
}

nav { padding: 16px 0; flex: 1; }
nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s;
}
nav a:hover { color: #fff; background: rgba(255,255,255,0.04); }
nav a.active {
  color: #fff;
  background: rgba(201,151,58,0.1);
  border-left-color: var(--gold);
  font-weight: 500;
}
nav a .nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-role {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 100px;
  margin-top: 4px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
}
.sidebar-user .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  float: right;
  margin-top: -28px;
}
.sidebar-user .user-avatar-initials {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  float: right;
  margin-top: -28px;
}
.sidebar-logout {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-logout:hover { color: rgba(255,255,255,0.6); }

/* ── Role switcher dropdown ── */
.role-switcher { position: relative; display: inline-block; }
.role-switcher-toggle {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.role-switcher-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--ink);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  min-width: 140px;
  overflow: hidden;
  z-index: 100;
}
.role-switcher:hover .role-switcher-menu { display: block; }
.role-switcher-menu button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.role-switcher-menu button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.role-switcher-menu button.active { color: var(--gold); font-weight: 600; }

/* ── Top bar ── */
.topbar {
  grid-column: 2;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title {
  font-family: 'Gelasio', serif;
  font-size: 20px;
  color: var(--ink);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Main content area ── */
.content { grid-column: 2; padding: 32px; overflow-y: auto; }

/* ── Page header (title + action button row) ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-family: 'Gelasio', serif;
  font-size: 22px;
  color: var(--ink);
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 {
  font-family: 'Gelasio', serif;
  font-size: 16px;
  color: var(--ink);
}
.card-body { padding: 20px 24px; }

/* ── Stats grid ── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-value {
  font-family: 'Gelasio', serif;
  font-size: 32px;
  color: var(--ink);
  line-height: 1;
}
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: #f8fafc; }
.table-empty { text-align: center; color: var(--muted); padding: 32px !important; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-open            { color: var(--open);        background: var(--open-bg); }
.badge-in_progress     { color: var(--in-progress); background: var(--in-progress-bg); }
.badge-waiting_on_amazon { color: var(--waiting);   background: var(--waiting-bg); }
.badge-resolved        { color: var(--resolved);    background: var(--resolved-bg); }
.badge-closed          { color: var(--closed);      background: var(--closed-bg); }
.badge-low             { color: var(--low);         background: var(--low-bg); }
.badge-medium          { color: var(--medium);      background: var(--medium-bg); }
.badge-high            { color: var(--high);        background: var(--high-bg); }
.badge-urgent          { color: var(--urgent);      background: var(--urgent-bg); }
.badge-success         { color: var(--resolved);    background: var(--resolved-bg); }
.badge-secondary       { color: var(--closed);      background: var(--closed-bg); }
.badge-info            { color: var(--open);        background: var(--open-bg); }
.badge-warning         { color: var(--high);        background: var(--high-bg); }
.badge-error           { color: var(--urgent);      background: var(--urgent-bg); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-gold     { background: var(--gold); color: #fff; }
.btn-navy     { background: var(--navy); color: #fff; }
.btn-outline  { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: #aab; opacity: 1; }
.btn-danger   { background: #fee2e2; color: #991b1b; }
.btn-secondary { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--blue); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alerts ── */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
}
.alert p { margin: 0; }
.alert-success { background: var(--resolved-bg); color: var(--resolved); }
.alert-error   { background: var(--urgent-bg);   color: var(--urgent); }
.alert-warning { background: var(--high-bg);     color: var(--high); }
.alert-info    { background: var(--open-bg);     color: var(--open); }

/* ── Modals ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}
.modal-title {
  font-family: 'Gelasio', serif;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 20px;
}

/* ── Auth layout ── */
body.auth-layout {
  background: var(--navy);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  background: var(--ink);
  border-right: 1px solid rgba(201,151,58,0.15);
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  bottom: -120px; right: -120px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,151,58,0.1) 0%, transparent 70%);
  pointer-events: none;
}
.auth-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.auth-card {
  background: var(--cream);
  border-radius: 18px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}
.auth-heading {
  font-family: 'Gelasio', serif;
  font-size: 24px;
  color: var(--ink);
  margin-bottom: 6px;
}
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.auth-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 14px;
}
.auth-input:focus { border-color: var(--blue); }
.btn-magic {
  width: 100%;
  padding: 13px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-magic:hover { background: var(--blue); }
.btn-google {
  width: 100%;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.btn-google:hover { border-color: #aab; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-size: 12px;
  color: var(--muted);
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-fine { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; line-height: 1.5; }
.auth-fine a { color: var(--ink); }

/* ── Role picker ── */
body.picker-layout {
  background: var(--navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.picker-card {
  background: var(--cream);
  border-radius: 18px;
  padding: 48px 40px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}
.picker-heading {
  font-family: 'Gelasio', serif;
  font-size: 24px;
  color: var(--ink);
  margin-bottom: 6px;
}
.picker-sub { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.logo-wordmark {
  font-family: 'Gelasio', serif;
  font-size: 22px;
  color: #fff;
  text-decoration: none;
}
.logo-wordmark span { color: var(--gold); }

/* ── Responsive ── */
@media (max-width: 768px) {
  body.app-layout { grid-template-columns: 1fr; }
  body.app-layout .sidebar { display: none; }
  body.app-layout .topbar,
  body.app-layout .content { grid-column: 1; }
  body.auth-layout { grid-template-columns: 1fr; }
  .auth-left { display: none; }
  .auth-right { padding: 40px 24px; align-items: flex-start; padding-top: 60px; }
  .form-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}

/* ── Filter bar ── */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-bar select {
  padding: 9px 36px 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a7a9a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 148px;
  transition: border-color 0.15s;
}
.filter-bar select:hover,
.filter-bar select:focus { border-color: var(--gold); }

/* ── Mobile: portal pages ── */
@media (max-width: 768px) {
  .dash-stats   { grid-template-columns: repeat(2, 1fr) !important; }
  .dash-cols    { grid-template-columns: 1fr !important; }
  .res-stats    { grid-template-columns: 1fr !important; }
  .profile-grid { grid-template-columns: 1fr !important; }
  .clients-card .client-row { flex-wrap: wrap; }
  .team-card { padding: 16px; }
  .team-members { gap: 6px; }
  /* Hide lower-priority ticket table columns on mobile */
  .tickets-table th:nth-child(4),
  .tickets-table td:nth-child(4),
  .tickets-table th:nth-child(5),
  .tickets-table td:nth-child(5),
  .tickets-table th:nth-child(6),
  .tickets-table td:nth-child(6),
  .admin-table th:nth-child(4),
  .admin-table td:nth-child(4),
  .admin-table th:nth-child(5),
  .admin-table td:nth-child(5),
  .admin-table th:nth-child(6),
  .admin-table td:nth-child(6) { display: none; }
}
@media (max-width: 480px) {
  .dash-stats { grid-template-columns: 1fr !important; }
  .dash-stat-value { font-size: 28px; }
}

/* ── Rich text content (Quill output) ── */
.rich-content p { margin: 0 0 10px; }
.rich-content p:last-child { margin-bottom: 0; }
.rich-content ul, .rich-content ol { padding-left: 20px; margin: 0 0 10px; }
.rich-content li { margin-bottom: 4px; }
.rich-content strong { font-weight: 700; }
.rich-content em { font-style: italic; }
.rich-content a { color: var(--gold); }
