/* ================================================================
   BỆNH VIỆN PHỤ SẢN HẢI PHÒNG — Medical Protocol Website
   Design System & Component Styles
   ================================================================ */

/* ================================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ================================================================ */
:root {
  /* Brand Colors — lấy từ logo (indigo/navy) */
  --primary:        #2D2B8C;
  --primary-dark:   #201E6B;
  --primary-mid:    #3D3AAA;
  --primary-light:  #ECEEFF;
  --primary-xlight: #F5F6FF;

  /* Semantic Colors */
  --success:        #0F7B55;
  --success-light:  #E7F8F2;
  --warning:        #B45309;
  --warning-light:  #FEF3C7;
  --danger:         #B91C1C;
  --danger-light:   #FEE2E2;
  --info:           #1D4ED8;
  --info-light:     #DBEAFE;

  /* Severity Colors */
  --sev-low:        #0F7B55;
  --sev-low-bg:     #E7F8F2;
  --sev-medium:     #B45309;
  --sev-medium-bg:  #FEF3C7;
  --sev-high:       #B91C1C;
  --sev-high-bg:    #FEE2E2;

  /* Neutrals */
  --bg:             #F4F5FF;
  --bg-white:       #FFFFFF;
  --border:         #DDE0F5;
  --border-strong:  #B8BCE8;
  --text:           #1A1840;
  --text-secondary: #5A5880;
  --text-muted:     #8886AA;
  --shadow-sm:      0 1px 3px rgba(29, 27, 100, 0.08);
  --shadow:         0 4px 16px rgba(29, 27, 100, 0.10);
  --shadow-md:      0 8px 24px rgba(29, 27, 100, 0.14);
  --shadow-lg:      0 16px 48px rgba(29, 27, 100, 0.18);

  /* Protocol Column Colors */
  --col-assess:   #2D2B8C;
  --col-lab:      #0F6B8C;
  --col-treat:    #0F7B55;
  --col-nutri:    #7B5F0F;
  --col-comm:     #6B2D8C;
  --col-care:     #8C2D2D;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs:   11px;
  --font-size-sm:   13px;
  --font-size-base: 15px;
  --font-size-md:   16px;
  --font-size-lg:   18px;
  --font-size-xl:   20px;
  --font-size-2xl:  24px;
  --font-size-3xl:  28px;

  /* Spacing */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   12px;
  --space-base: 16px;
  --space-lg:   20px;
  --space-xl:   24px;
  --space-2xl:  32px;
  --space-3xl:  48px;

  /* Radii */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-md:  14px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 200ms ease;
  --transition-slow: 350ms ease;

  /* Header height */
  --header-height: 64px;
}

/* ================================================================
   2. RESET & BASE
   ================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: var(--font-size-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ================================================================
   3. LAYOUT
   ================================================================ */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: var(--space-base);
  padding-top: 100px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   4. HEADER
   ================================================================ */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--primary);
  box-shadow: 0 2px 12px rgba(29, 27, 100, 0.25);
}

.header-inner {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--space-base);
  gap: var(--space-sm);
}

/* Logo + Title */
.header-logo-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.header-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
}

.header-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title-main {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.header-title-sub {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
}

/* Back button */
.btn-back {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background var(--transition);
}
.btn-back:hover  { background: rgba(255,255,255,0.15); }
.btn-back:active { background: rgba(255,255,255,0.25); }
.btn-back svg { width: 22px; height: 22px; }

/* Admin link */
.btn-admin-link {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  flex-shrink: 0;
  transition: all var(--transition);
}
.btn-admin-link:hover  { color: #fff; background: rgba(255,255,255,0.15); }
.btn-admin-link svg { width: 20px; height: 20px; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  padding: 4px var(--space-base) 8px;
  gap: 4px;
  background: rgba(0,0,0,0.15);
}

.bc-item {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.bc-item:hover { color: #fff; }
.bc-item.active { color: #fff; font-weight: 500; cursor: default; }

.bc-sep {
  width: 14px;
  height: 14px;
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
}



/* Adjust main-content when breadcrumb visible */
.has-breadcrumb .main-content {
  padding-top: 130px;
}
@media (min-width: 600px) {
  .has-breadcrumb .main-content {
    padding-top: 150px;
  }
}

/* ================================================================
   5. SECTION HEADERS
   ================================================================ */
.page-header {
  text-align: center;
  padding: var(--space-lg) 0 var(--space-xl);
}

.page-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ================================================================
   6. CARDS — Department & Condition
   ================================================================ */
.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
}

/* Department Card */
.dept-card {
  flex: 1 1 280px;
  max-width: 100%;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

@media (min-width: 500px) {
  .dept-card {
    max-width: calc(50% - var(--space-md) / 2);
  }
}

.dept-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 16px;
  background: linear-gradient(to right, var(--dept-color, var(--primary)) 4px, transparent 4px);
  border-top-left-radius: calc(var(--radius-md) - 1.5px);
  border-bottom-left-radius: calc(var(--radius-md) - 1.5px);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.dept-card:hover {
  border-color: var(--dept-color, var(--primary));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dept-card:active { transform: scale(0.98); }

.dept-card-name {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text);
}

.dept-card-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.dept-card-arrow {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  align-self: flex-end;
  transition: transform var(--transition), color var(--transition);
}
.dept-card:hover .dept-card-arrow {
  transform: translateX(4px);
  color: var(--dept-color, var(--primary));
}

/* Condition Card */
.cond-list { display: flex; flex-direction: column; gap: var(--space-md); }

.cond-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-base) var(--space-lg);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  position: relative;
  overflow: hidden;
}

.cond-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 16px;
  background: linear-gradient(to right, var(--sev-color, var(--primary)) 4px, transparent 4px);
  border-top-left-radius: calc(var(--radius-md) - 1.5px);
  border-bottom-left-radius: calc(var(--radius-md) - 1.5px);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.cond-card:hover {
  border-color: var(--sev-color, var(--primary));
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
}
.cond-card:active { transform: scale(0.98); }

.cond-card-body { flex: 1; min-width: 0; }

.cond-card-name {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.cond-card-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Severity Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-low    { background: var(--sev-low-bg);    color: var(--sev-low);    }
.badge-medium { background: var(--sev-medium-bg); color: var(--sev-medium); }
.badge-high   { background: var(--sev-high-bg);   color: var(--sev-high);   }

/* ================================================================
   7. PROTOCOL VIEW
   ================================================================ */
.protocol-header {
  margin-bottom: var(--space-lg);
}

.protocol-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.protocol-dept-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.protocol-sev-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

/* Day Tabs */
.day-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-base);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  white-space: nowrap;
  transition: all var(--transition);
  cursor: pointer;
  flex-shrink: 0;
}
.day-tab:hover { border-color: var(--primary); color: var(--primary); }
.day-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 43, 140, 0.35);
}

/* Protocol Cards Grid */
.protocol-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  animation: fadeIn 0.2s ease;
}

/* Individual Protocol Card (each column) */
.proto-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.proto-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-base);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.proto-card-header.col-assess  { background: var(--col-assess); }
.proto-card-header.col-lab     { background: var(--col-lab);    }
.proto-card-header.col-treat   { background: var(--col-treat);  }
.proto-card-header.col-nutri   { background: var(--col-nutri);  }
.proto-card-header.col-comm    { background: var(--col-comm);   }
.proto-card-header.col-care    { background: var(--col-care);   }

.proto-card-header svg {
  width: 16px; height: 16px;
  opacity: 0.9;
  flex-shrink: 0;
}

.proto-card-body {
  padding: var(--space-base);
}

.proto-card-body ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proto-card-body li {
  display: flex;
  gap: 8px;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--text);
}

.proto-card-body li::before {
  content: '•';
  color: var(--primary);
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Care Level Card — special style */
.care-level-value {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--col-care);
  text-align: center;
  padding: var(--space-sm) 0;
  letter-spacing: 1px;
}

/* Empty protocol */
.protocol-empty {
  text-align: center;
  padding: var(--space-3xl) var(--space-base);
  color: var(--text-muted);
}

/* ================================================================
   8. ADMIN — Login
   ================================================================ */
.admin-login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: var(--space-xl);
}

.admin-login-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.admin-login-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto var(--space-base);
  display: block;
  border: 3px solid var(--primary-light);
}

.admin-login-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: var(--space-xs);
}

.admin-login-sub {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-xl);
}

/* ================================================================
   9. FORM ELEMENTS
   ================================================================ */
.form-group {
  margin-bottom: var(--space-base);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.form-label .req { color: var(--danger); }

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  color: var(--text);
  background: var(--bg-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 43, 140, 0.12);
}

.form-input[type="password"] {
  letter-spacing: 2px;
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

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

/* Input with icon */
.input-wrap {
  position: relative;
}
.input-wrap .form-input { padding-left: 40px; }
.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ================================================================
   10. BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  border: 1.5px solid transparent;
  font-family: var(--font);
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(45,43,140,0.25);
}
.btn-primary:hover  { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(45,43,140,0.35); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #991b1b; }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #0a5c3e; }

.btn-sm {
  padding: 6px 12px;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon svg { width: 16px; height: 16px; }

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ================================================================
   11. ADMIN PANEL
   ================================================================ */
.admin-wrap {
  padding-bottom: var(--space-3xl);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  gap: var(--space-base);
  flex-wrap: wrap;
}

.admin-header-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text);
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.admin-tab:hover { color: var(--text); background: rgba(45,43,140,0.06); }
.admin-tab.active {
  background: var(--bg-white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Admin List */
.admin-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.admin-list-item {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-base);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}
.admin-list-item:hover { border-color: var(--primary-mid); }

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

.admin-list-item-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.admin-list-item-meta {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.admin-list-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Admin Form Panel */
.admin-form-panel {
  background: var(--primary-xlight);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.admin-form-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.admin-form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-base);
  flex-wrap: wrap;
}

/* Section divider */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-xl) 0;
}

/* Add button row */
.add-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-base);
}

/* Protocol admin — select filters */
.admin-filters {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-base);
  flex-wrap: wrap;
}

.admin-filters .form-select {
  flex: 1;
  min-width: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-base);
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-base);
  opacity: 0.3;
}
.empty-state p {
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-base);
}

/* Color dot */
.color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.1);
}

/* Active toggle */
.status-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.status-active   { background: var(--sev-low-bg);    color: var(--sev-low);    }
.status-inactive { background: var(--sev-high-bg);   color: var(--sev-high);   }

/* ================================================================
   12. TOAST
   ================================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: #fff;
  background: var(--text);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: slideUp 0.25s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger);  }
.toast.warning { background: var(--warning); }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);    }
}

/* ================================================================
   13. LOADING
   ================================================================ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-large {
  width: 52px; height: 52px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(29, 27, 100, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background: var(--primary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-2xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-base);
  box-shadow: var(--shadow-lg);
}

.loading-box p {
  color: rgba(255,255,255,0.85);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

/* ================================================================
   14. MODAL
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-base);
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.modal-msg {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ================================================================
   15. UTILITY CLASSES
   ================================================================ */
.hidden { display: none !important; }
.mt-sm  { margin-top: var(--space-sm); }
.mt-base { margin-top: var(--space-base); }
.mt-lg  { margin-top: var(--space-lg); }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: var(--font-size-sm); }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm      { gap: var(--space-sm); }
.w-full      { width: 100%; }

/* Color swatch input */
input[type="color"] {
  width: 40px; height: 36px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  background: var(--bg-white);
}

/* Protocol day label badge in admin */
.day-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 4px;
}

/* ================================================================
   16. RESPONSIVE — Tablet & Desktop
   ================================================================ */
@media (min-width: 600px) {
  .main-content {
    padding-top: 120px;
    padding-bottom: var(--space-xl);
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
  }
  .header-logo  { width: 48px; height: 48px; }
  .header-title-main { font-size: var(--font-size-base); }
}

@media (min-width: 720px) {
  .main-content {
    padding-top: 70px;
    padding-bottom: var(--space-xl);
    padding-left: var(--space-base);
    padding-right: var(--space-base);
  }

  .protocol-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }

  /* Care level spans full width on desktop */
  .proto-card.col-care-wrap {
    grid-column: 1 / -1;
  }
}

/* ================================================================
   16.5 CUSTOM SELECT DROPDOWN (cái vuông cái bo góc fix)
   ================================================================ */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  color: var(--text);
  background: var(--bg-white);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  user-select: none;
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 43, 140, 0.12);
}

.custom-select-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-arrow svg {
  width: 16px;
  height: 16px;
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 150;
  max-height: 240px;
  overflow-y: auto;
  animation: dropdownFadeIn var(--transition) ease;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.custom-select-option {
  padding: 10px 14px;
  font-size: var(--font-size-sm);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.custom-select-option:first-child {
  border-top-left-radius: calc(var(--radius) - 1.5px);
  border-top-right-radius: calc(var(--radius) - 1.5px);
}

.custom-select-option:last-child {
  border-bottom-left-radius: calc(var(--radius) - 1.5px);
  border-bottom-right-radius: calc(var(--radius) - 1.5px);
}

.custom-select-option:hover {
  background: var(--primary-xlight);
  color: var(--primary);
}

.custom-select-option.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ================================================================
   17. PRINT STYLES (optional)
   ================================================================ */
@media print {
  .header, .day-tabs, .btn, .admin-tabs { display: none !important; }
  .main-content { padding: 0; margin: 0; }
  .proto-card { break-inside: avoid; }
}
