/* ==========================================================================
   Admin Panel Styles — ระบบจัดการเอกสาร ITA โรงพยาบาลแม่วงก์
   ========================================================================== */

.admin-body {
  background: #F1F5F9;
  min-height: 100vh;
}

/* Admin Navbar */
.admin-nav {
  background: var(--brand-navy);
  color: #fff;
  border-bottom: 3px solid var(--brand-accent);
  position: sticky;
  top: 0;
  z-index: 40;
}

.admin-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.admin-brand-badge {
  background: var(--brand-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.admin-menu {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-menu a {
  color: rgba(255, 255, 255, 0.85);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-menu a:hover,
.admin-menu a.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.admin-menu a.logout-link {
  background: rgba(239, 68, 68, 0.22);
  color: #FEE2E2;
}

.admin-menu a.logout-link:hover {
  background: rgba(239, 68, 68, 0.38);
  color: #fff;
}

/* Admin Container */
.admin-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 52px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 600;
  color: var(--brand-navy);
}

.page-subtitle {
  margin: 3px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon.navy { background: #EBF3FA; color: var(--brand-primary); }
.kpi-icon.blue { background: #E0F2FE; color: #0284C7; }
.kpi-icon.red  { background: #FEE2E2; color: #DC2626; }
.kpi-icon.teal { background: #CCFBF1; color: #0F766E; }

.kpi-num {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-main);
}

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* Cards & Tables */
.panel-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-light);
  background: #FAFCFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--brand-navy);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: #F8FAFC;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: #FAFBFD;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.active { background: #DCFCE7; color: #166534; }
.status-badge.hidden { background: #F1F5F9; color: #64748B; }
.status-badge.default { background: #DBEAFE; color: #1D4ED8; }
.status-badge.pdf { background: #FEE2E2; color: #B91C1C; }
.status-badge.link { background: #E0F2FE; color: #0369A1; }
.status-badge.heading { background: #E2E8F0; color: #334155; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

.btn-icon {
  padding: 5px 7px;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
  color: #fff;
}

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

.btn-accent:hover {
  background: #0063A7;
  color: #fff;
}

.btn-success {
  background: #0F766E;
  color: #fff;
}

.btn-success:hover {
  background: #115E59;
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: var(--brand-soft);
}

.btn-danger-outline {
  background: #fff;
  border-color: #FECACA;
  color: #B91C1C;
}

.btn-danger-outline:hover {
  background: #FEF2F2;
  border-color: #EF4444;
}

.btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Admin MOIT Management Cards */
.admin-moit-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
}

.admin-moit-card.open {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-md);
}

.admin-moit-head {
  padding: 14px 18px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.admin-moit-card.open .admin-moit-head {
  background: #F4F8FC;
  border-bottom: 1px solid var(--border-light);
}

.admin-moit-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 240px;
  cursor: pointer;
}

.admin-moit-body {
  display: none;
  padding: 14px 18px 18px;
}

.admin-moit-card.open .admin-moit-body {
  display: block;
}

.admin-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 7px;
  background: #fff;
  transition: border-color 0.15s ease;
}

.admin-item-row:hover {
  border-color: #CBD5E1;
}

.admin-item-row.is-heading {
  background: #F1F5F9;
  border-left: 3px solid var(--brand-primary);
}

.admin-item-row.indent-1 { margin-left: 18px; }
.admin-item-row.indent-2 { margin-left: 36px; }
.admin-item-row.is-hidden-item { opacity: 0.55; }

.admin-item-info {
  flex: 1;
  min-width: 0;
}

.admin-item-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-main);
  word-break: break-word;
}

.admin-item-row.is-heading .admin-item-title {
  font-weight: 700;
  color: var(--brand-navy);
}

.admin-item-url {
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 620px;
}

/* Forms & Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  padding: 16px 20px;
  background: var(--brand-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 16.5px;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-foot {
  padding: 14px 20px;
  background: #F8FAFC;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--text-main);
  background: #fff;
  transition: border-color 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(0, 119, 200, 0.12);
}

.form-hint {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Type Selector Tabs inside Add/Edit Item Modal */
.type-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.type-tab-btn {
  padding: 10px 8px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.type-tab-btn.active {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
  color: var(--brand-navy);
}

/* Drag & Drop PDF Dropzone */
.dropzone {
  border: 2px dashed #94A3B8;
  border-radius: var(--radius-md);
  padding: 22px 16px;
  text-align: center;
  background: #F8FAFC;
  cursor: pointer;
  transition: all 0.16s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand-accent);
  background: #EFF6FF;
}

.dropzone-title {
  font-weight: 700;
  color: var(--brand-navy);
  margin-bottom: 4px;
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.dropzone-selected {
  margin-top: 10px;
  padding: 8px 12px;
  background: #DCFCE7;
  color: #166534;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: none;
}

.dropzone-selected.show {
  display: block;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1E3F66 0%, #2F5B88 60%, #1A365D 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}

.login-banner {
  width: 100%;
  display: block;
  border-bottom: 3px solid var(--brand-accent);
}

.login-body {
  padding: 26px 28px 28px;
}

.alert-box {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
}

.alert-success {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #166534;
}

@media (max-width: 720px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .admin-item-row {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-item-row.indent-1 { margin-left: 8px; }
  .admin-item-row.indent-2 { margin-left: 16px; }
}
