/* ==============================================================================
 * iCares Med-OS Design System
 * Primary: Teal (#0d9488) | Secondary: Navy (#0f172a / #1e293b)
 * Clean, High-Readability Healthcare SaaS UI
 * ============================================================================== */

:root {
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  
  --navy-50: #f8fafc;
  --navy-100: #f1f5f9;
  --navy-200: #e2e8f0;
  --navy-700: #334155;
  --navy-800: #1e293b;
  --navy-900: #0f172a;

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --app-bg: #f8fafc;
  --card-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.05);
  --card-hover-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
}

body {
  font-family: var(--font-family);
  background-color: var(--app-bg);
  color: var(--navy-900);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==============================================================================
 * Layout Structure
 * ============================================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--navy-900);
  color: #f1f5f9;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none !important;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-icon-box {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.45);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8 !important;
  font-weight: 700;
  padding: 0.85rem 0.75rem 0.4rem 0.75rem;
  margin-top: 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: #e2e8f0 !important;
  border-radius: 8px;
  text-decoration: none !important;
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.15s ease-in-out;
  margin-bottom: 0.25rem;
}

.sidebar-link i {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
  color: #2dd4bf !important;
  transition: color 0.15s ease-in-out;
}

.sidebar-link:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.12) !important;
  transform: translateX(3px);
}

.sidebar-link:hover i {
  color: #5eead4 !important;
}

.sidebar-link.active {
  color: #ffffff !important;
  background: linear-gradient(90deg, rgba(13, 148, 136, 0.45), rgba(13, 148, 136, 0.15)) !important;
  border-left: 4px solid #14b8a6 !important;
  font-weight: 600;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.1);
}

.sidebar-link.active i {
  color: #2dd4bf !important;
}

.sidebar-link.sidebar-link-upcoming {
  color: #cbd5e1 !important;
}

.sidebar-link.sidebar-link-upcoming i {
  color: #94a3b8 !important;
}

.sidebar-link.sidebar-link-upcoming:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
}

.sidebar-link.sidebar-link-upcoming:hover i {
  color: #2dd4bf !important;
}

.sidebar-badge-fase {
  background: rgba(13, 148, 136, 0.25);
  color: #5eead4;
  border: 1px solid rgba(45, 212, 191, 0.4);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.sidebar-role-text {
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 500;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

/* Main Container */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Topbar */
.app-topbar {
  height: var(--topbar-height);
  background-color: #ffffff;
  border-bottom: 1px solid var(--navy-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.btn-sidebar-toggle {
  background: transparent;
  border: 1px solid var(--navy-200);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy-700);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sidebar-toggle:hover {
  background-color: var(--navy-100);
  color: var(--navy-900);
}

.branch-selector-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--navy-50);
  border: 1px solid var(--navy-200);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tenant-badge {
  background: var(--teal-50);
  color: var(--teal-700);
  border: 1px solid var(--teal-200);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  transition: background 0.15s;
}

.user-profile-menu:hover {
  background-color: var(--navy-50);
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-600), var(--navy-800));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Page Content */
.app-content {
  flex: 1;
  padding: 1.5rem;
}

/* ==============================================================================
 * Cards & Dashboard Aesthetics
 * ============================================================================== */
.card-med {
  background: #ffffff;
  border: 1px solid var(--navy-200);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-med:hover {
  box-shadow: var(--card-hover-shadow);
}

.card-kpi {
  padding: 1.25rem;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--navy-200);
  position: relative;
  overflow: hidden;
}

.kpi-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.kpi-icon-teal {
  background: var(--teal-50);
  color: var(--teal-600);
}

.kpi-icon-navy {
  background: var(--navy-100);
  color: var(--navy-800);
}

.kpi-icon-amber {
  background: #fef3c7;
  color: #d97706;
}

.kpi-icon-emerald {
  background: #d1fae5;
  color: #059669;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy-900);
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==============================================================================
 * Small Premium Controls & Form Standards (from Knowledge Base)
 * ============================================================================== */
.form-control-sm-premium,
.form-select-sm-premium {
  height: 32px;
  border-radius: 6px;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  font-size: 0.875rem;
  padding: 0.25rem 0.65rem;
  transition: all 0.15s ease-in-out;
}

.form-control-sm-premium:focus,
.form-select-sm-premium:focus {
  background-color: #ffffff;
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
  outline: none;
}

.form-label-premium {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin-bottom: 0.35rem;
}

/* Buttons */
.btn-teal {
  background-color: var(--teal-600);
  border-color: var(--teal-600);
  color: #ffffff;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.btn-teal:hover {
  background-color: var(--teal-700);
  border-color: var(--teal-700);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.3);
}

.btn-navy {
  background-color: var(--navy-900);
  border-color: var(--navy-900);
  color: #ffffff;
  font-weight: 600;
  border-radius: 8px;
}

.btn-navy:hover {
  background-color: var(--navy-800);
  color: #ffffff;
}

/* ==============================================================================
 * Teal Utilities & Badges (High Contrast Theme Standards)
 * ============================================================================== */
.bg-teal {
  background-color: var(--teal-600) !important;
  color: #ffffff !important;
}

.text-teal {
  color: var(--teal-600) !important;
}

.text-teal-700 {
  color: var(--teal-700) !important;
}

.text-teal-800 {
  color: var(--teal-800) !important;
}

.bg-teal-subtle {
  background-color: #ccfbf1 !important;
  color: #0f766e !important;
}

.border-teal {
  border-color: var(--teal-600) !important;
}

.border-teal-subtle,
.border-teal-200 {
  border-color: #99f6e4 !important;
}

.btn-outline-teal {
  color: var(--teal-600) !important;
  border-color: var(--teal-600) !important;
  background-color: transparent !important;
}

.btn-outline-teal:hover {
  background-color: var(--teal-600) !important;
  border-color: var(--teal-600) !important;
  color: #ffffff !important;
}

.badge.bg-teal-subtle {
  background-color: #ccfbf1 !important;
  color: #0f766e !important;
  border: 1px solid #99f6e4 !important;
}

.badge-queue-no {
  background-color: #0f766e !important;
  color: #ffffff !important;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  display: inline-block;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.25);
}

/* Navy Theme Utilities */
.bg-navy {
  background-color: #0f172a !important;
  color: #ffffff !important;
}

.badge.bg-navy {
  background-color: #0f172a !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
}

.text-navy {
  color: #0f172a !important;
}

.border-navy {
  border-color: #0f172a !important;
}

/* HTMX Loading Bar */
.htmx-indicator-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--teal-500), #38bdf8);
  z-index: 9999;
  transition: width 0.3s ease;
}

.htmx-request .htmx-indicator-bar {
  width: 100%;
  animation: htmx-loading 1.2s infinite ease-in-out;
}

@keyframes htmx-loading {
  0% { width: 0%; left: 0; }
  50% { width: 70%; left: 15%; }
  100% { width: 100%; left: 100%; }
}

/* ==============================================================================
 * Cashier Payment Method Selector Cards
 * ============================================================================== */
.payment-method-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.5rem;
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  color: #334155 !important;
  text-decoration: none !important;
  user-select: none;
  position: relative;
}

.payment-method-card .method-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
  transition: transform 0.15s ease;
}

.payment-method-card .method-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155 !important;
  transition: color 0.15s ease;
}

.payment-method-card:hover {
  border-color: var(--teal-600) !important;
  background-color: #f0fdfa !important;
  color: var(--teal-800) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px -2px rgba(13, 148, 136, 0.15);
}

.payment-method-card:hover .method-label {
  color: var(--teal-800) !important;
}

.payment-method-card:hover .method-icon {
  transform: scale(1.1);
}

.payment-method-card.active {
  border-color: var(--teal-600) !important;
  background-color: #f0fdfa !important;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.25), 0 2px 4px rgba(0, 0, 0, 0.05);
}

.payment-method-card.active .method-label {
  color: var(--teal-800) !important;
  font-weight: 700;
}

.payment-method-card .check-indicator {
  display: none;
  position: absolute;
  top: 4px;
  right: 6px;
  width: 16px;
  height: 16px;
  background-color: var(--teal-600);
  color: #ffffff;
  border-radius: 50%;
  font-size: 10px;
  align-items: center;
  justify-content: center;
}

.payment-method-card.active .check-indicator {
  display: flex;
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}

