/* =========================================
   1. VARIABLES & RESET & FONTS
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
  --p-10: #05152E;
  --p-20: #0A295C;
  --p-30: #0F3E8A;
  --p-60: #3C83F6;
  --p-80: #9DC1FA;
  --p-95: #E7EFFE;

  --s-60: #3CD4F6;
  --s-90: #CEF4FD;

  --t-50: #E51A7C;
  --t-20: #5C0A32;
  --t-90: #FAD1E5;

  --primary: var(--p-60);
  --primary-dark: var(--p-30);
  --accent: var(--t-50);
  --highlight: var(--s-60);

  --brand-gradient: linear-gradient(135deg, var(--p-60) 0%, var(--t-50) 100%);

  --bg-body: #F7F5F2;
  --bg-surface: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #F0F4F8;

  --text-main: var(--p-10);
  --text-muted: #5e6c84;
  --border-light: #e2e8f0;
  --border-focus: var(--p-60);

  --success-bg: #d1fae5;
  --success-text: #065f46;
  --error-bg: #ffe4e6;
  --error-text: #881337;
  --info-bg: var(--p-95);
  --info-text: var(--p-30);

  --header-h: 110px;
  /* Increased to accommodate 80px logo + padding */
  --footer-h: 60px;
  --container-max: 1200px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px 0 rgba(5, 21, 46, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(5, 21, 46, 0.1), 0 2px 4px -1px rgba(5, 21, 46, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(5, 21, 46, 0.1), 0 4px 6px -2px rgba(5, 21, 46, 0.05);
  --shadow-float: 0 20px 25px -5px rgba(5, 21, 46, 0.1), 0 10px 10px -5px rgba(5, 21, 46, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  /*line-height: 1.6;*/
  padding-bottom: var(--footer-h);
  -webkit-font-smoothing: antialiased;
}

/* Utils */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--p-30);
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
  font-style: italic;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 700;
}

a:hover {
  color: var(--t-50);
  text-decoration: underline;
}

/* =========================================
   2. LAYOUT & CONTAINERS
   ========================================= */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

.card,
.account-section,
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

/* Grid & Utilities */
.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.gap-md {
  gap: 24px;
}

.mt-2 {
  margin-top: 12px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-3 {
  margin-bottom: 24px;
}

/* =========================================
   3. HEADER / NAVBAR
   ========================================= */
.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--p-95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--p-20);
  text-decoration: none !important;
}

.navbar .brand .brand-text {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--t-50);
  font-weight: 700;
  margin-left: -5px;
  background: var(--p-95);
  padding: 2px 8px;
  border-radius: 4px;
}

.navbar .brand img {
  height: 80px;
  width: auto;
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links>a,
.nav-links .nav-link,
.nav-links .submenu-toggle {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links>a:hover,
.nav-links .nav-link:hover,
.nav-links .submenu-toggle:hover,
.nav-links>a.active,
.nav-item.has-submenu.open .submenu-toggle {
  color: var(--primary);
  background: var(--p-95);
  font-weight: 700;
}

/* Dropdowns / Submenus */
.nav-item.has-submenu {
  position: relative;
}

.nav-item.has-submenu .nav-submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  display: none;
  z-index: 1000;
}

.nav-item.has-submenu.open .nav-submenu {
  display: block;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.nav-item.has-submenu .nav-submenu a {
  display: block;
  padding: 10px 20px;
  color: var(--text-main);
  font-weight: 400;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-item.has-submenu .nav-submenu a:hover {
  background: var(--p-95);
  color: var(--primary);
}

.environment-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.1);
}


/* Quota Bar */
.desktop-quota {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--p-95);
  border-radius: var(--radius-md);
  color: var(--p-20);
  font-size: 0.85rem;
  font-weight: 700;
}

.quota-text {
  font-family: 'Space Mono', monospace;
  letter-spacing: -0.02em;
}

.quota-icon {
  width: 18px;
  height: 18px;
}

/* =========================================
   4. BUTTONS & INPUTS
   ========================================= */
.button,
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 24px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  background: var(--brand-gradient);
  color: #fff;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(60, 131, 246, 0.3);
}

.button:hover,
.st-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px -3px rgba(60, 131, 246, 0.4);
}

.button.secondary,
.st-btn.secondary {
  background: #fff;
  color: var(--p-30);
  border: 2px solid var(--border-light);
  box-shadow: none;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="time"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  min-height: 48px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--p-95);
}

label {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 8px;
  color: var(--p-20);
  display: block;
  text-transform: uppercase;
}

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

/* =========================================
   5. LOGIN PAGE
   ========================================= */
.login-wrap {
  background: var(--bg-body);
  background-image:
    linear-gradient(rgba(60, 131, 246, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 131, 246, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.login-card .text-center {
  margin-bottom: 24px;
}

.login-card .module-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--t-50);
  letter-spacing: 0.2em;
  margin-top: 8px;
  background: var(--p-95);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
}

.login-card img.logo {
  height: 80px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* =========================================
   6. MODALS & OVERLAYS
   ========================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
}

.modal-overlay.show {
  display: flex !important;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  animation: modalScale 0.3s ease-out;
}

.modal-card.wide {
  max-width: 1200px;
  width: 95%;
  height: 90vh;
}

@keyframes modalScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  flex-shrink: 0;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--p-30);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.modal-footer .pagination {
  margin-top: 0;
  width: 100%;
  justify-content: center;
}

.login-card .card {
  background: #fff;
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  border: 1px solid var(--p-95);
  position: relative;
  overflow: hidden;
}

.login-card .card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--brand-gradient);
}

.login-card button.st-btn {
  margin-top: 32px;
}

/* =========================================
   6. TABLES & LISTS
   ========================================= */
.search-section {
  background: #fff;
  padding: 15px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 2px;
}

.results-section {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: nowrap;
  /* Force single row */
}



.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table tr:nth-child(even) {
  background-color: rgba(60, 131, 246, 0.03);
}

.results-table th {
  background: var(--p-95);
  color: var(--p-30);
  font-weight: 700;
  text-transform: uppercase;
  padding: 8px;
  text-align: left;
  border-bottom: 2px solid var(--p-20);
}

.results-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive Table into Cards */
@media (max-width: 768px) {
  .results-table thead {
    display: none;
  }

  .results-table tr {
    display: flex;
    flex-direction: column;
    padding: 16px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  .results-table tr:nth-child(even) {
    background: #fff;
  }

  .results-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--p-95);
    text-align: right;
  }

  .results-table td:last-child {
    border-bottom: none;
    padding-top: 16px;
    justify-content: center;
  }

  .results-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--p-30);
    text-transform: uppercase;
    font-size: 0.75rem;
    text-align: left;
    margin-right: 16px;
    flex-shrink: 0;
  }

  .results-table td .st-btn {
    width: 100%;
  }
}

/* Badges for reports */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-ok,
.badge-online {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-muted {
  background: #f1f5f9;
  color: #64748b;
}

/* =========================================
   7. FOOTER
   ========================================= */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: #fff;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--p-30);
}

/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 992px) {
  .nav-links {
    display: none;
  }

  .navbar {
    padding: 0 16px;
    height: 64px;
    justify-content: flex-start;
    /* Ensure left-to-right */
    gap: 12px;
  }

  .nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .navbar .brand img {
    height: 36px;
    /* Slightly smaller for mobile but visible */
  }

  .desktop-quota {
    display: none;
  }

  .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .environment-right {
    margin-left: auto;
    /* Push language select to right */
    gap: 8px;
  }
}

/* Hamburger & Drawer */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1001;
}

@media (min-width: 993px) {
  .hamburger {
    display: none;
  }
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--p-10);
  transition: all 0.3s;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: #fff;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: none;
  /* JS will set to block */
}

.drawer.open {
  transform: translateX(0);
  display: flex !important;
  flex-direction: column;
}

.drawer-header {
  padding: 24px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--p-30);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drawer-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
}

.drawer-link:hover,
.drawer-link.active {
  background: var(--p-95);
  color: var(--primary);
}

.drawer-item.has-submenu {
  display: flex;
  flex-direction: column;
}

.drawer-submenu {
  display: none;
  flex-direction: column;
  padding-left: 24px;
  gap: 4px;
  margin-top: 4px;
  border-left: 2px solid var(--p-95);
  margin-left: 24px;
}

.drawer-item.has-submenu.open .drawer-submenu {
  display: flex;
}

.drawer-submenu a {
  padding: 8px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.drawer-submenu a:hover {
  background: var(--p-95);
  color: var(--primary);
}

.drawer-link i:first-child {
  width: 20px;
  text-align: center;
}

.submenu-chevron {
  margin-left: auto;
  font-size: 0.8rem;
  transition: transform 0.3s;
}

.drawer-item.has-submenu.open .submenu-chevron {
  transform: rotate(180deg);
}

.drawer-quota {
  margin-top: auto;
  padding: 16px;
  background: var(--p-95);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.drawer-quota-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--p-20);
}

.drawer-quota-icon {
  width: 20px;
  height: 20px;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.backdrop.show {
  display: block !important;
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--p-95);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Page Containers */
.mailing-container,
.clinic-container {
  padding-top: 40px;
  padding-bottom: 60px;
}

/* UI Refinements Round 3 */
.input-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  max-width: 400px;
}

.input-wrapper input#quickSearch {
  padding-right: 40px;
}

#clearSearch {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: color 0.2s;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border-light);
  color: var(--p-30);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}

.pagination a:hover {
  background: var(--p-95);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .current {
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  box-shadow: 0 4px 6px -1px rgba(60, 131, 246, 0.3);
}

.pagination span {
  border: none;
  background: transparent;
  width: auto;
  min-width: auto;
}

#clearSearch:hover {
  color: var(--accent);
}

.select-toolbar {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.select-toolbar label {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-weight: 400;
  cursor: pointer;
}