/* ===========================
   UTILITY
   =========================== */
.hidden { display: none !important; }

/* Full-width override — admin panel uses all available screen width */
.app-shell {
  max-width: 100% !important;
  margin: 0 !important;
  padding-bottom: 0 !important;
}

.main {
  padding: 0 !important;
}

/* ===========================
   ADMIN TOAST
   =========================== */
.admin-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  width: calc(100vw - 40px);
  pointer-events: none;
}

.admin-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px solid;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  pointer-events: all;
  animation: adminToastIn 0.28s ease;
  font-size: 0.9rem;
  font-weight: 500;
}

.admin-toast.success { border-color: #4ade80; color: #166534; }
.admin-toast.error   { border-color: #f87171; color: #991b1b; }
.admin-toast.info    { border-color: #60a5fa; color: #1e40af; }

.admin-toast .t-icon { font-size: 1rem; flex-shrink: 0; }

@keyframes adminToastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===========================
   LOGIN
   =========================== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 100px);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 440px;
}

.admin-status-bar {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--coral);
  text-align: center;
  min-height: 1.2em;
}

/* ===========================
   LAYOUT
   =========================== */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 82px);
}

/* ===========================
   SIDEBAR
   =========================== */
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #07314f 0%, #0b5f86 100%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 16px;
}

.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
}

.admin-sidebar-label {
  color: rgba(255,255,255,0.4);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 16px 3px;
  margin-top: 4px;
}

.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  position: relative;
}

.admin-sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-sidebar a.active { background: rgba(255,255,255,0.14); color: #fff; border-left-color: #78c7e8; }

.admin-sidebar-icon { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-badge {
  margin-left: auto;
  background: var(--coral, #f06a5b);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  display: none;
}

.sidebar-badge-urgent { background: #dc2626; }

/* ===========================
   MAIN CONTENT
   =========================== */
.admin-main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
  background: #f2f7fb;
  overflow-x: hidden;
}

/* ===========================
   SECTION TITLES
   =========================== */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.section-title-row h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-deep);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-badge {
  background: #dbeafe;
  color: var(--primary-deep);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}

.section-link {
  font-size: 0.82rem;
  color: var(--primary-deep);
  text-decoration: none;
  font-weight: 600;
}

.section-link:hover { text-decoration: underline; }

/* Dashboard mini-lists */
.dash-list-item {
  padding: 9px 0;
  border-bottom: 1px solid #f0f6fb;
  font-size: 0.9rem;
  line-height: 1.4;
}
.dash-list-item:last-child { border-bottom: none; }

/* ===========================
   METRIC CARDS
   =========================== */
.admin-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.metric-card {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #dbeafe;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 6px rgba(11,95,134,0.07);
}

.metric-card .metric-icon { font-size: 1.5rem; flex-shrink: 0; }
.metric-card .metric-num  { font-size: 1.55rem; font-weight: 800; color: var(--primary-deep); line-height: 1; margin-bottom: 2px; }
.metric-card .metric-label { font-size: 0.74rem; color: var(--muted); font-weight: 600; }

/* ===========================
   ADMIN SECTIONS
   =========================== */
.admin-section {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #dbeafe;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 8px rgba(11,95,134,0.05);
}

.admin-section h4 { font-size: 1rem; font-weight: 700; color: var(--primary-deep); margin: 0 0 4px; }
.admin-section .section-intro { font-size: 0.83rem; color: var(--muted); margin: 0 0 14px; }

.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-section-head h4 { margin: 0; }

/* ===========================
   TABLE
   =========================== */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #eaf2f8;
  flex-wrap: wrap;
}

.table-search {
  flex: 1;
  min-width: 180px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  background: #f8fbfd;
}

.table-search:focus { border-color: var(--primary-deep); background: #fff; }

.table-filter {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: #f8fbfd;
  outline: none;
  cursor: pointer;
}

.table-filter:focus { border-color: var(--primary-deep); }

.table-wrap { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  background: #f0f7fc;
  padding: 9px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--muted);
  border-bottom: 1.5px solid #d6eaf8;
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #eaf2f8;
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:nth-child(even) td { background: #f9fcff; }
.admin-table tr:hover td { background: #ebf5fd !important; }

.loading-cell { color: var(--muted); font-style: italic; padding: 24px; text-align: center; }

/* ===========================
   STATUS BADGES
   =========================== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.badge-confirmed { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.badge-pending   { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.badge-cancelled { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-urgent    { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-high      { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.badge-normal    { background: #f0f9ff; color: #0c4a6e; border: 1px solid #bae6fd; }
.badge-active    { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.badge-inactive  { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }

.ad-pos-badge {
  display: inline-block;
  background: #e8f4fd;
  color: var(--primary-deep);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

/* ===========================
   STATUS FILTER TABS
   =========================== */
.status-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.status-tab {
  background: #f0f7fc;
  border: 1.5px solid #d6eaf8;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.14s;
  font-family: var(--font-body);
}

.status-tab:hover { background: #dbeafe; color: var(--primary-deep); }
.status-tab.active { background: var(--primary-deep); color: #fff; border-color: var(--primary-deep); }

/* ===========================
   FORMS
   =========================== */
.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.form-grid-2col label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.form-grid-2col input,
.form-grid-2col select,
.form-grid-2col textarea {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.14s;
  background: #fafcfe;
}

.form-grid-2col input:focus,
.form-grid-2col select:focus,
.form-grid-2col textarea:focus {
  border-color: var(--primary-deep);
  background: #fff;
}

.full-col { grid-column: 1 / -1; }

.field-hint { font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-top: 2px; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}

/* ===========================
   TOPBAR INFO
   =========================== */
.admin-topbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.admin-topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-deep);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===========================
   TWO-COL
   =========================== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

/* ===========================
   ACTIONS INLINE
   =========================== */
.actions-inline {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===========================
   MINI CARD (dashboard lists)
   =========================== */
.mini-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #eaf2f8;
  margin-bottom: 8px;
  font-size: 0.85rem;
  background: #fafcff;
}

.mini-card:last-child { margin-bottom: 0; }
.mini-card-title { font-weight: 600; color: #1e3a5f; }
.mini-card-sub { font-size: 0.78rem; color: var(--muted); }

/* ===========================
   THREAD VIEWER
   =========================== */
.thread-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  min-height: 500px;
}

.thread-list-panel {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #dbeafe;
  overflow-y: auto;
  max-height: 640px;
}

.thread-item {
  padding: 12px 14px;
  border-bottom: 1px solid #eaf2f8;
  cursor: pointer;
  transition: background 0.12s;
}

.thread-item:last-child { border-bottom: none; }
.thread-item:hover { background: #f0f7fc; }
.thread-item.active { background: #dbeafe; border-left: 3px solid var(--primary-deep); }

.thread-item-subject {
  font-weight: 700;
  font-size: 0.88rem;
  color: #1e3a5f;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item-meta {
  font-size: 0.76rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.thread-viewer-panel {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #dbeafe;
  display: flex;
  flex-direction: column;
  max-height: 640px;
}

.thread-viewer-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.thread-viewer-header {
  padding: 14px 18px;
  border-bottom: 1px solid #eaf2f8;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.thread-viewer-subject { font-weight: 700; font-size: 1rem; color: #1e3a5f; margin-bottom: 3px; }
.thread-viewer-from { font-size: 0.8rem; color: var(--muted); }

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thread-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.thread-msg.user {
  background: #f0f7fc;
  border: 1px solid #dbeafe;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.thread-msg.admin-msg {
  background: var(--primary-deep);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.thread-msg-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; }
.thread-msg.admin-msg .thread-msg-meta { color: rgba(255,255,255,0.65); }
.thread-msg-body { line-height: 1.5; }

.thread-reply-form {
  padding: 12px 16px;
  border-top: 1px solid #eaf2f8;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.thread-reply-input {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 100px;
}

.thread-reply-input:focus { border-color: var(--primary-deep); }

/* ===========================
   RESPONSIVE
   =========================== */
/* ===========================
   ACCESSIBILITY / HEALTHCARE FORMS
   =========================== */
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.92rem;
  cursor: pointer;
  line-height: 1.4;
}
.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  accent-color: var(--primary-deep, #0b5f86);
  cursor: pointer;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 1000px) {
  .thread-layout { grid-template-columns: 1fr; }
  .thread-list-panel { max-height: 260px; }
  .form-grid-2col { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    gap: 2px;
    min-height: unset;
  }
  .admin-sidebar-brand { display: none; }
  .admin-sidebar-label { display: none; }
  .admin-sidebar a {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 7px 10px;
    font-size: 0.8rem;
  }
  .admin-sidebar a.active { border-bottom-color: #78c7e8; border-left-color: transparent; }
  .admin-main { padding: 16px; }
}
