/* Dental Clinic Management System - Unified Design System */
/* Inherits root variables from index.html: --bg, --card, --ink, --ink-soft, --line, --teal, --teal-deep, --mint, --radius, --shadow */

:root {
  --sys-sidebar-w: 260px;
  --sys-header-h: 68px;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
}

html.dark {
  --success: #34d399;
  --success-bg: #064e3b;
  --warning: #fbbf24;
  --warning-bg: #451a03;
  --danger: #f87171;
  --danger-bg: #450a0a;
  --info: #38bdf8;
  --info-bg: #0c4a6e;
  --purple: #a78bfa;
  --purple-bg: #2e1065;
}

/* Base Clinic System Container */
#clinicAppContainer {
  display: none;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
}

#clinicAppContainer.active {
  display: flex;
  flex-direction: column;
}

/* System Header / Topbar */
.sys-topbar {
  height: var(--sys-header-h);
  background: color-mix(in srgb, var(--card) 95%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.sys-topbar-start {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sys-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.sys-brand-badge {
  font-size: 11px;
  background: var(--mint);
  color: var(--teal-deep);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
html.dark .sys-brand-badge { color: var(--teal); }

.sys-topbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sys-user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--mint);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-deep);
}
html.dark .sys-user-badge { color: var(--teal); }

.sys-user-role {
  font-size: 11px;
  background: var(--teal);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
}

.sys-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: .2s;
}

.sys-icon-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.sys-icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--card);
}

/* Layout Split: Sidebar + Main Content */
.sys-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--sys-header-h));
}

.sys-sidebar {
  width: var(--sys-sidebar-w);
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 14px;
  flex-shrink: 0;
}

.sys-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sys-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: none;
  transition: all .2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-family: inherit;
}

.sys-nav-item svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.sys-nav-item:hover {
  background: var(--mint);
  color: var(--teal-deep);
}
html.dark .sys-nav-item:hover { color: var(--teal); }

.sys-nav-item.active {
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 4px 14px -3px rgba(31,138,128,0.5);
}
.sys-nav-item.active svg { stroke: #fff; }

.sys-nav-badge {
  margin-right: auto;
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  color: inherit;
}

.sys-nav-item:not(.active) .sys-nav-badge {
  background: var(--mint);
  color: var(--teal);
}

.sys-main {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

/* Mobile Bottom Navigation */
.sys-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: color-mix(in srgb, var(--card) 95%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 85;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.sys-bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  padding: 8px 0;
  position: relative;
}

.sys-bottom-item svg {
  width: 20px;
  height: 20px;
}

.sys-bottom-item.active {
  color: var(--teal);
}

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

.sys-kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}

.sys-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.sys-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sys-kpi-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.sys-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sys-kpi-icon svg { width: 18px; height: 18px; }

.sys-kpi-val {
  font-size: 26px;
  font-weight: 800;
  font-family: 'Cairo', sans-serif;
  color: var(--ink);
  line-height: 1.2;
}

.sys-kpi-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* Sections & Panels */
.sys-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
}

.sys-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.sys-panel-title {
  font-size: 18px;
  font-weight: 800;
  font-family: 'Cairo', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status Badges */
.sys-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.sys-badge.warning { background: var(--warning-bg); color: var(--warning); }
.sys-badge.info { background: var(--info-bg); color: var(--info); }
.sys-badge.teal { background: var(--mint); color: var(--teal); }
.sys-badge.purple { background: var(--purple-bg); color: var(--purple); }
.sys-badge.success { background: var(--success-bg); color: var(--success); }
.sys-badge.danger { background: var(--danger-bg); color: var(--danger); }
.sys-badge.secondary { background: var(--line); color: var(--ink-soft); }

/* Queue Cards */
.sys-queue-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sys-queue-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all .2s ease;
  position: relative;
}

.sys-queue-item.in_treatment {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--mint) 40%, var(--card));
  box-shadow: 0 4px 18px -4px rgba(31,138,128,0.25);
}

.sys-queue-num {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--mint);
  color: var(--teal-deep);
  font-family: 'Cairo', sans-serif;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
html.dark .sys-queue-num { color: var(--teal); }
.sys-queue-item.in_treatment .sys-queue-num {
  background: var(--teal);
  color: #fff;
}

.sys-queue-info {
  flex: 1;
}

.sys-queue-info h4 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sys-queue-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.sys-queue-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Patient Timeline Card Stack */
.sys-timeline {
  position: relative;
  padding-right: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sys-timeline::before {
  content: '';
  position: absolute;
  right: 11px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--line);
}

.sys-timeline-node {
  position: relative;
}

.sys-timeline-dot {
  position: absolute;
  right: -28px;
  top: 18px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 2px var(--mint);
}

.sys-timeline-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 4px 16px -6px rgba(0,0,0,0.05);
}

.sys-timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 10px;
}

.sys-timeline-date {
  font-family: 'Cairo', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--teal);
}

.sys-timeline-row {
  margin-bottom: 12px;
}

.sys-timeline-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sys-timeline-text {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
}

/* Tables */
.sys-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.sys-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13.5px;
}

.sys-table th {
  background: var(--mint);
  color: var(--teal-deep);
  font-weight: 800;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
html.dark .sys-table th { color: var(--teal); }

.sys-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

.sys-table tbody tr:hover {
  background: color-mix(in srgb, var(--mint) 25%, transparent);
}

/* Form Elements */
.sys-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.sys-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sys-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.sys-input, .sys-select, .sys-textarea {
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.sys-input:focus, .sys-select:focus, .sys-textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 15%, transparent);
}

.sys-textarea {
  min-height: 90px;
  resize: vertical;
}

/* Modals */
.sys-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sys-modal-backdrop.active {
  display: flex;
}

.sys-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,0.3);
  animation: modalScaleIn .25s ease-out;
  overflow: hidden;
  position: relative;
}

.sys-modal > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.sys-modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--card);
}

.sys-modal-head h3 {
  font-size: 18px;
  font-weight: 800;
  font-family: 'Cairo', sans-serif;
}

.sys-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sys-modal-body::-webkit-scrollbar {
  width: 6px;
}

.sys-modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.sys-modal-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.sys-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--teal);
}

.sys-modal-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  background: var(--card);
}

/* Toast Notifications Container */
.sys-toast-container {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.sys-toast {
  pointer-events: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.25);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: toastSlideIn .3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlideIn {
  from { transform: translateX(-40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.sys-toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sys-toast-content b {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
  font-family: 'Cairo', sans-serif;
}

.sys-toast-content p {
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* Quick Login Card & Auth View */
.sys-auth-wrap {
  min-height: calc(100vh - var(--sys-header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.sys-auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.sys-quick-logins {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

/* Responsive Overrides */
@media (max-width: 900px) {
  .sys-sidebar {
    display: none;
  }
  .sys-bottom-nav {
    display: flex;
  }
  .sys-main {
    padding: 18px 16px 84px; /* bottom padding for bottom nav */
  }
  .sys-topbar {
    padding: 0 16px;
  }
  .sys-queue-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .sys-queue-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Notification Dropdown & Badges */
.notif-wrapper {
  position: relative;
}

.notif-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--card);
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.3);
  z-index: 120;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn .2s ease-out;
}

.notif-dropdown.active {
  display: flex;
}

.notif-dropdown-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--mint) 30%, var(--card));
}

.notif-dropdown-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
  color: inherit;
}

.notif-item:hover {
  background: var(--mint);
}

.notif-item.unread {
  background: color-mix(in srgb, var(--mint) 40%, var(--card));
}

.notif-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
}

.notif-body {
  flex: 1;
}

.notif-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--ink);
}

.notif-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.notif-time {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.notif-dropdown-foot {
  padding: 10px;
  text-align: center;
  border-top: 1px solid var(--line);
  background: var(--card);
}

/* User Menu & Clean Header System */
.sys-user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink);
  transition: all .2s ease;
  font-family: inherit;
}

.sys-user-menu-btn:hover {
  border-color: var(--teal);
  background: var(--mint);
}

.user-menu-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  font-family: 'Cairo', sans-serif;
  flex-shrink: 0;
}

.user-menu-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: right;
  line-height: 1.2;
}

.user-menu-info b {
  font-size: 12.5px;
  white-space: nowrap;
}

.user-menu-role {
  font-size: 10.5px;
  color: var(--teal);
  font-weight: 700;
}

.sys-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 310px;
  max-width: calc(100vw - 20px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.28);
  z-index: 130;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn .2s ease-out;
}

.sys-menu-dropdown.active {
  display: flex;
}

.sys-menu-user-card {
  padding: 16px;
  background: color-mix(in srgb, var(--mint) 45%, var(--card));
  display: flex;
  align-items: center;
  gap: 12px;
}

.sys-menu-avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.sys-menu-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.sys-menu-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sys-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: right;
  width: 100%;
  transition: background .15s ease;
  color: var(--ink);
  font-family: inherit;
}

.sys-menu-item:hover {
  background: var(--mint);
}

.sys-menu-item.danger:hover {
  background: var(--danger-bg);
}

.sys-menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sys-menu-item-text {
  flex: 1;
  min-width: 0;
}

.sys-menu-item-text b {
  display: block;
  font-size: 13.5px;
}

/* Responsive Mobile Header & Screen Adjustments */
@media (max-width: 860px) {
  .sys-topbar {
    padding: 0 14px;
    height: 58px;
  }
  .sys-topbar-start .brand-text span {
    display: none !important;
  }
  .sys-topbar-start .brand-text b {
    font-size: 14px !important;
    white-space: nowrap !important;
  }
  .sys-topbar-end {
    gap: 8px !important;
  }
  .sys-user-menu-btn {
    padding: 2px !important;
    border: none !important;
    background: transparent !important;
  }
  .sys-hide-mobile {
    display: none !important;
  }
  .notif-dropdown {
    left: -48px !important;
    width: min(340px, calc(100vw - 20px)) !important;
  }
  .sys-menu-dropdown {
    left: 0 !important;
    width: min(310px, calc(100vw - 20px)) !important;
  }
}

@media (max-width: 600px) {
  .sys-modal-backdrop {
    padding: 8px;
    align-items: center;
  }
  .sys-modal {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 18px;
  }
  .sys-modal-head {
    padding: 14px 16px;
  }
  .sys-modal-body {
    padding: 16px;
    gap: 14px;
  }
  .sys-modal-foot {
    padding: 12px 16px;
  }
}

/* =========================================================
   Enterprise UI Dialogs, Prompts, Confirms & Toast System
   ========================================================= */

.sys-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 24, 23, 0.68) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 1000 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}

.sys-dialog-backdrop.active {
  display: flex !important;
  animation: dialogFadeIn .2s ease-out forwards;
}

@keyframes dialogFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.sys-dialog-card {
  background: var(--card) !important;
  border: 1px solid var(--line) !important;
  border-radius: 22px !important;
  width: 100% !important;
  max-width: 450px !important;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35) !important;
  overflow: hidden !important;
  animation: dialogPopIn .24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  flex-direction: column;
  margin: auto;
}

.sys-dialog-body {
  padding: 24px 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.sys-dialog-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.sys-dialog-badge.info {
  background: var(--mint);
  color: var(--teal);
  border: 2px solid color-mix(in srgb, var(--teal) 20%, transparent);
}

.sys-dialog-badge.success {
  background: var(--success-bg);
  color: var(--success);
  border: 2px solid color-mix(in srgb, var(--success) 20%, transparent);
}

.sys-dialog-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 2px solid color-mix(in srgb, var(--warning) 20%, transparent);
}

.sys-dialog-badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 2px solid color-mix(in srgb, var(--danger) 25%, transparent);
}

.sys-dialog-title {
  font-size: 18px;
  font-weight: 800;
  font-family: 'Cairo', sans-serif;
  color: var(--ink);
  margin: 0 0 6px 0;
  line-height: 1.35;
  width: 100%;
}

.sys-dialog-text {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 14px 0;
  width: 100%;
}

.sys-dialog-actions {
  padding: 14px 20px 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: color-mix(in srgb, var(--card) 95%, var(--bg));
  border-top: 1px solid var(--line);
  width: 100%;
}

.btn-danger {
  background: var(--danger) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 700 !important;
  border-radius: 999px !important;
  padding: 10px 22px !important;
  cursor: pointer !important;
  transition: all .2s ease !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Cairo', sans-serif !important;
  font-size: 14px !important;
}

.btn-danger:hover {
  background: #dc2626 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--danger) 40%, transparent);
}

/* Toast Notifications */
.sys-toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.sys-toast {
  pointer-events: auto;
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  animation: toastSlideIn .3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  direction: rtl;
  transition: transform .25s ease, opacity .25s ease;
}

.sys-toast.leaving {
  opacity: 0;
  transform: translateX(-35px);
}

.sys-toast-success {
  border-right: 4px solid var(--success);
}

.sys-toast-error {
  border-right: 4px solid var(--danger);
}

.sys-toast-warning {
  border-right: 4px solid var(--warning);
}

.sys-toast-info {
  border-right: 4px solid var(--teal);
}

.sys-toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}

.sys-toast-success .sys-toast-icon {
  background: var(--success-bg);
  color: var(--success);
}

.sys-toast-error .sys-toast-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.sys-toast-warning .sys-toast-icon {
  background: var(--warning-bg);
  color: var(--warning);
}

.sys-toast-info .sys-toast-icon {
  background: var(--mint);
  color: var(--teal);
}

.sys-toast-content {
  flex: 1;
  min-width: 0;
}

.sys-toast-msg {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  word-break: break-word;
}

.sys-toast-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 6px;
  transition: color .15s;
}

.sys-toast-close:hover {
  color: var(--ink);
}

.sys-toast-bar {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 3px;
  width: 100%;
  background: var(--teal);
  animation: toastProgressBar linear forwards;
  transform-origin: right;
}

.sys-toast-success .sys-toast-bar {
  background: var(--success);
}

.sys-toast-error .sys-toast-bar {
  background: var(--danger);
}

.sys-toast-warning .sys-toast-bar {
  background: var(--warning);
}

@keyframes toastProgressBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
