/* =============================================================================
   RUTS SSO Portal — Stylesheet (Grid Card Layout)
   ============================================================================= */

:root {
  --primary: #1a3a6c;
  --primary-light: #2a5298;
  --primary-dark: #0d1f3c;
  --accent: #f0a500;
  --accent-light: #ffd166;
  --surface: #ffffff;
  --bg-gradient: linear-gradient(160deg, #0d1f3c 0%, #1a3a6c 40%, #2a5298 100%);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.18);
  --radius: 16px;
  --radius-sm: 12px;
  --font: 'Noto Sans Thai', 'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-primary);
}

/* --- Loading Screen --- */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s ease-in-out infinite;
}

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

/* --- Header --- */
.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  height: 36px;
  width: auto;
}

.logo-text {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.logo-ruts {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2px;
}

.logo-sso {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #e08900);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.user-info-header {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.user-display-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.user-org-name {
  font-size: 0.7rem;
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* --- Profile Section --- */
.profile-section {
  padding: 2rem 1.5rem 0.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
}

.profile-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #e08900);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--primary-dark);
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(240, 165, 0, 0.3);
}

.profile-info { flex: 1; }

.profile-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.profile-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
}

.profile-badge.badge-staff {
  background: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
}

.profile-badge.badge-student {
  background: rgba(202, 138, 4, 0.2);
  color: var(--accent-light);
}

.profile-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.detail-item svg {
  opacity: 0.6;
  flex-shrink: 0;
}

/* --- Apps Section --- */
.apps-section {
  padding: 1.5rem 1.5rem 1rem;
  max-width: 960px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* Tab Group */
.tab-group {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab {
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
  font-family: var(--font);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.tab.active {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 600;
}

.tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
}

/* --- App Cards Grid --- */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.app-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text-dark);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.app-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
  transform: scaleX(0);
  transition: transform 0.3s;
}

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

.app-card:hover::after {
  transform: scaleX(1);
}

.app-icon-wrapper {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-color, #1a3a6c) 10%, white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-icon {
  font-size: 1.5rem;
}

.app-text {
  flex: 1;
}

.app-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 0.15rem;
  line-height: 1.3;
}

.app-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* --- Footer --- */
.portal-footer {
  text-align: center;
  padding: 1.5rem;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.72rem;
  line-height: 1.6;
  max-width: 960px;
  margin: 0 auto;
}

/* --- Header Button & Responsive Action Enhancements --- */
.btn-header-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-dev-header {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border: none;
  color: white !important;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  transition: all 0.2s;
}

.btn-dev-header:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
}

.btn-admin-header {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  color: white !important;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
}

.btn-admin-header:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.45);
}

/* =============================================================================
   ★ Comprehensive Multi-Screen Responsive System (320px - 4K) ★
   ============================================================================= */

/* 1. Large Screens & 4K (>= 1200px) */
@media (min-width: 1200px) {
  .profile-section,
  .apps-section,
  .portal-footer {
    max-width: 1120px;
  }
  .apps-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
}

/* 2. Medium Screens & Laptops (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
  .portal-header {
    padding: 0.75rem 1.25rem;
  }
  .user-menu {
    gap: 0.6rem;
  }
  .apps-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
  }
  .user-org-name {
    max-width: 140px;
  }
}

/* 3. Tablets & Small Laptops (768px - 991px) */
@media (max-width: 991px) {
  .portal-header {
    padding: 0.65rem 1rem;
  }
  .user-menu {
    gap: 0.5rem;
  }
  /* Collapse header action button labels to icons on tablet */
  .btn-header-action .btn-text {
    display: none;
  }
  .btn-header-action {
    padding: 7px 10px !important;
    border-radius: 8px;
  }
  .user-org-name {
    display: none;
  }
  .user-display-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .apps-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }
}

/* 4. Mobile Devices (< 768px) */
@media (max-width: 767px) {
  .portal-header {
    padding: 0.5rem 0.75rem;
  }
  
  .user-menu {
    gap: 0.4rem;
  }

  .user-info-header {
    display: none;
  }

  /* Hide header button text on mobile */
  .btn-header-action .btn-text {
    display: none;
  }

  .btn-header-action {
    padding: 7px 8px !important;
    min-width: 34px;
    justify-content: center;
  }

  /* On mobile header, hide the 2FA button because it is already prominent in profile card */
  .portal-header .btn-device-manage {
    display: none !important;
  }

  .profile-section {
    padding: 1rem 0.75rem 0.5rem;
  }

  .profile-card {
    flex-direction: column;
    text-align: center;
    padding: 1.25rem 1rem;
    gap: 0.85rem;
  }

  .profile-details {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .profile-actions {
    justify-content: center;
    width: 100%;
  }

  .profile-actions button {
    flex: 1 1 140px;
    justify-content: center;
  }

  .apps-section {
    padding: 1rem 0.75rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .tab-group {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 1;
    text-align: center;
  }

  .apps-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .app-card {
    padding: 1rem 0.6rem;
  }

  .app-icon-wrapper {
    width: 44px;
    height: 44px;
  }

  .app-icon {
    font-size: 1.3rem;
  }

  .app-name {
    font-size: 0.8rem;
  }

  .app-desc {
    font-size: 0.68rem;
  }
}

/* 5. Extra Small Mobile (< 400px) */
@media (max-width: 400px) {
  .logo-sso {
    display: none;
  }
  .logo-ruts {
    font-size: 1.15rem;
  }
  .header-logo {
    height: 28px;
  }
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  .apps-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
}

/* --- Modal 2FA Device Cards Responsive --- */
.modal-device-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s;
}

@media (max-width: 540px) {
  .modal-device-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .modal-device-card > button {
    width: 100%;
    justify-content: center;
    padding: 10px 16px !important;
  }
}

/* --- Print --- */
@media print {
  body { background: #fff; color: #333; }
  .portal-header { background: var(--primary) !important; print-color-adjust: exact; }
  .btn-logout { display: none; }
}
/* --- Button: Manage 2FA & Devices (Modern Gradient Style) --- */
.btn-device-manage {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  border: none;
  color: #ffffff !important;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.btn-device-manage:hover {
  background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%);
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.45);
  filter: brightness(1.06);
}

/* --- Light Theme Overrides (High Contrast & Clear Readability) --- */
body.light-theme {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #0f172a;
  --surface: #ffffff;
  --bg-gradient: linear-gradient(160deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  color: #0f172a;
}

body.light-theme .portal-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid #cbd5e1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

body.light-theme .logo-ruts {
  color: #d97706;
}

body.light-theme .logo-sso {
  color: #334155;
  font-weight: 600;
}

body.light-theme .user-display-name {
  color: #0f172a;
  font-weight: 700;
}

body.light-theme .user-org-name {
  color: #475569;
  font-weight: 500;
}

body.light-theme .user-avatar {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.25);
}

body.light-theme .btn-theme {
  color: #334155 !important;
}

body.light-theme .btn-theme:hover {
  background: #e2e8f0;
}

body.light-theme .btn-logout {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  font-weight: 600;
}

body.light-theme .btn-logout:hover {
  background: #fecaca;
  color: #b91c1c;
}

/* Profile Card in Light Theme */
body.light-theme .profile-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06);
}

body.light-theme .profile-name {
  color: #0f172a;
  font-weight: 700;
}

body.light-theme .profile-badge {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

body.light-theme .profile-badge.badge-staff {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
}

body.light-theme .profile-badge.badge-student {
  background: #fefce8;
  border-color: #fef08a;
  color: #a16207;
  font-weight: 600;
}

body.light-theme .detail-item {
  color: #334155;
  font-weight: 500;
}

body.light-theme .detail-item svg {
  stroke: #2563eb;
  opacity: 0.9;
}

/* Systems Section in Light Theme */
body.light-theme .section-title {
  color: #0f172a;
}

body.light-theme .section-subtitle {
  color: #475569;
  font-weight: 500;
}

body.light-theme .tab-group {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}

body.light-theme .tab {
  color: #475569;
  font-weight: 600;
}

body.light-theme .tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.6);
  color: #0f172a;
}

body.light-theme .tab.active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* App Cards in Light Theme */
body.light-theme .app-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

body.light-theme .app-card:hover {
  background: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 12px 28px -5px rgba(37, 99, 235, 0.18);
  transform: translateY(-4px);
}

body.light-theme .app-name {
  color: #0f172a;
  font-weight: 700;
}

body.light-theme .app-desc {
  color: #475569;
  font-weight: 500;
}

body.light-theme .portal-footer {
  color: #64748b;
  border-top: 1px solid #cbd5e1;
}

body.light-theme .portal-footer p {
  color: #64748b;
  font-weight: 500;
}

/* =============================================================================
   Password Reminder Banner (Soft Reminder)
   ============================================================================= */
.pwd-reminder-banner {
  max-width: 1200px;
  margin: 0 auto 1.5rem auto;
  padding: 1.1rem 1.5rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.pwd-reminder-banner::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #f59e0b, #d97706);
  border-radius: 4px 0 0 4px;
}

.pwd-reminder-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.pwd-reminder-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.pwd-reminder-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pwd-reminder-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fbbf24;
  letter-spacing: 0.3px;
}

.pwd-reminder-msg {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.pwd-reminder-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn-change-pwd {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a !important;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
  white-space: nowrap;
}

.btn-change-pwd:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.btn-dismiss-reminder {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.btn-dismiss-reminder:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Light Mode Overrides for Banner */
body.light-theme .pwd-reminder-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.08);
}
body.light-theme .pwd-reminder-title {
  color: #b45309;
}
body.light-theme .pwd-reminder-msg {
  color: #78350f;
}
body.light-theme .pwd-reminder-icon {
  background: #fef3c7;
  border-color: #fde68a;
  color: #d97706;
}
body.light-theme .btn-dismiss-reminder {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: #92400e;
}

@media (max-width: 768px) {
  .pwd-reminder-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    gap: 1rem;
  }
  .pwd-reminder-actions {
    width: 100%;
    justify-content: space-between;
  }
  .btn-change-pwd {
    flex: 1;
    justify-content: center;
  }
}

/* =============================================================================
   Logout / Confirmation Modal
   ============================================================================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
}
.modal-dialog {
  background: #ffffff;
  color: #0f172a;
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 2.25rem 2rem 1.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  position: relative;
  text-align: center;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-dialog .close-btn {
  position: absolute;
  right: 1.25rem;
  top: 1.25rem;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}
.modal-dialog .close-btn:hover { color: #ef4444; }
.modal-dialog .confirm-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fef3c7;
  color: #d97706;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 0 6px #fffbeb;
}
.modal-dialog .confirm-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.75rem;
}
.modal-dialog .confirm-desc {
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  text-align: left;
}
.modal-dialog .confirm-warning-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.86rem;
  color: #92400e;
  text-align: left;
  line-height: 1.5;
}
.modal-dialog .confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.modal-dialog .confirm-actions button {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
}
.modal-dialog .btn-cancel {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
}
.modal-dialog .btn-cancel:hover {
  background: #e2e8f0;
}
.modal-dialog .btn-confirm-logout {
  background: #ef4444;
  border: none;
  color: white;
}
.modal-dialog .btn-confirm-logout:hover {
  background: #dc2626;
}

/* =====================================================
   ★ Side Drawer — คู่มือการใช้งาน 2FA & ความปลอดภัย (Level 1) ★
   ===================================================== */

/* ม่านหลังโปร่งแสงสำหรับ Side Drawer */
.guide-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.guide-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* แผง Side Drawer สไลด์ออกมาจากขอบจอขวา */
.guide-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: #ffffff;
  color: #1e293b;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
}

.guide-drawer.active {
  transform: translateX(0);
}

/* ส่วนหัวของ Drawer */
.guide-drawer-header {
  padding: 20px 24px 16px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.guide-drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-drawer-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.guide-drawer-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  color: #0f172a;
}

.guide-drawer-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
}

.guide-drawer-close-btn {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: #64748b;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.guide-drawer-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: scale(1.05);
}

/* แท็บเลือกหัวข้อคู่มือ (Scroll แนวนอนได้บนมือถือ) */
.guide-drawer-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: none;
}

.guide-drawer-tabs::-webkit-scrollbar {
  display: none;
}

.guide-drawer-tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.guide-drawer-tab:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.guide-drawer-tab.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* ส่วนเนื้อหาของคู่มือ */
.guide-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* กล่องภาพรวมด้านบนของแต่ละแท็บ */
.guide-hero-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.guide-hero-icon {
  font-size: 28px;
  line-height: 1;
}

.guide-hero-title {
  font-size: 14px;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 4px;
}

.guide-hero-desc {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.5;
}

/* ขั้นตอนการใช้งาน (Step Cards) */
.guide-step-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.guide-step-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.guide-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.guide-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-step-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.guide-step-content {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.55;
  padding-left: 36px;
}

/* กล่องคำแนะนำ / เคล็ดลับ */
.guide-tip-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: #166534;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
}

/* ปุ่มเรียก Action จากในคู่มือโดยตรง */
.guide-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 16px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.guide-quick-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

/* รายการคำถามพบบ่อย (FAQ Accordion Card) */
.guide-faq-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.guide-faq-q {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.guide-faq-a {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.55;
  padding-left: 20px;
}

/* ส่วนท้ายของ Drawer */
.guide-drawer-footer {
  padding: 14px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.guide-footer-info {
  font-size: 11.5px;
  color: #64748b;
}

/* Responsive บนหน้าจอมือถือ */
@media (max-width: 600px) {
  .guide-drawer {
    width: 100vw;
  }
  .guide-drawer-header {
    padding: 16px;
  }
  .guide-drawer-tabs {
    padding: 8px 16px;
  }
  .guide-drawer-body {
    padding: 16px;
  }
  .guide-step-content {
    padding-left: 0;
    margin-top: 8px;
  }
}


