/* ============================================================
   PennAI HMS — Custom Component Overrides
   Works alongside Tailwind CSS CDN
   ============================================================ */

/* ── Font ───────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
body { font-family: 'Inter', ui-sans-serif, system-ui, sans-serif; }

/* ── Sidebar Layout ─────────────────────────────────────────── */
.hms-sidebar {
  width: 260px;
  min-width: 260px;
  background: #111827;
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 30;
  transform: translateX(0);
  transition: transform 300ms ease;
}

@media (max-width: 1023px) {
  .hms-sidebar { transform: translateX(-100%); }
  .hms-sidebar.is-open { transform: translateX(0); box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
}

.hms-main { margin-left: 260px; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
@media (max-width: 1023px) { .hms-main { margin-left: 0 !important; } }

/* ── Sidebar Brand ──────────────────────────────────────────── */
.sidebar-brand {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}
.sidebar-logo {
  width: 2.5rem; height: 2.5rem;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(124,58,237,0.4);
}
.sidebar-brand-name { font-weight: 800; font-size: 1rem; color: #f9fafb; line-height: 1.2; letter-spacing: -0.02em; }
.sidebar-tenant-name { font-size: 0.7rem; color: #6b7280; line-height: 1.2; display: block; }
.sidebar-close {
  position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #6b7280; cursor: pointer; padding: 0.25rem; font-size: 1rem;
}

/* ── Sidebar Nav ────────────────────────────────────────────── */
.sidebar-nav { padding: 0.75rem 0.5rem; flex: 1; }
.sidebar-section-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: #4b5563;
  padding: 1.25rem 0.75rem 0.375rem;
}
.sidebar-nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 150ms ease;
  cursor: pointer;
  user-select: none;
  border-left: 3px solid transparent;
}
.sidebar-nav-icon {
  width: 1.25rem; text-align: center; font-size: 0.95rem; flex-shrink: 0;
}
.sidebar-nav-item:hover { background: rgba(255,255,255,0.06); color: #f9fafb; }
.sidebar-nav-item[aria-current="page"] {
  background: linear-gradient(90deg, rgba(59,130,246,0.2), rgba(59,130,246,0.04));
  color: #60a5fa; font-weight: 600;
  border-left-color: #3b82f6;
}

/* ── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 1rem;
  background: rgba(0,0,0,0.15);
}
.sidebar-user { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-user-avatar {
  width: 2.25rem; height: 2.25rem;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white; flex-shrink: 0;
}
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; color: #f9fafb; display: block; }
.sidebar-user-role { font-size: 0.7rem; color: #6b7280; display: block; }
.sidebar-logout {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%;
  padding: 0.5rem 0.75rem; border-radius: 0.5rem;
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); cursor: pointer;
  color: #f87171; font-size: 0.8rem; font-weight: 600;
  transition: all 150ms ease;
}
.sidebar-logout:hover { background: rgba(239,68,68,0.2); }

/* ── Header ─────────────────────────────────────────────────── */
.hms-header {
  height: 64px;
  background: #111827;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; flex-shrink: 0;
  position: relative; z-index: 10;
}
.header-left, .header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-menu-btn {
  background: none; border: none; cursor: pointer; padding: 0.5rem;
  color: #9ca3af; border-radius: 0.5rem; transition: background 150ms ease;
}
.header-menu-btn:hover { background: #374151; color: #f9fafb; }
.header-page-title { font-weight: 600; font-size: 0.95rem; color: #f9fafb; }

.header-tenant-badge {
  display: flex; align-items: center;
  background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3);
  color: #60a5fa; padding: 0.35rem 0.85rem; border-radius: 9999px;
  font-size: 0.8rem; font-weight: 600;
}
.header-tenant-badge--super { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.3); color: #fbbf24; }

.header-pwa-btn, .header-icon-btn {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); cursor: pointer;
  color: #9ca3af; border-radius: 0.5rem;
  padding: 0.375rem 0.75rem; font-size: 0.85rem;
  display: flex; align-items: center;
  transition: all 150ms ease;
}
.header-pwa-btn:hover, .header-icon-btn:hover { background: #374151; color: #f9fafb; }

.header-user-dropdown { position: relative; }
.header-user-btn {
  display: flex; align-items: center; gap: 0.625rem;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); cursor: pointer;
  padding: 0.35rem 0.75rem; border-radius: 9999px; transition: background 150ms ease;
}
.header-user-btn:hover { background: #374151; }
.header-user-avatar {
  width: 1.75rem; height: 1.75rem;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: white;
}
.header-dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem);
  background: #1f2937; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.75rem; box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  min-width: 220px; z-index: 100; overflow: hidden;
}
.header-dropdown-user { padding: 1rem; background: rgba(0,0,0,0.2); border-bottom: 1px solid rgba(255,255,255,0.08); }
.header-dropdown-item {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.75rem 1rem; font-size: 0.875rem; color: #d1d5db;
  background: none; border: none; cursor: pointer; width: 100%; text-align: left;
  transition: all 150ms ease;
}
.header-dropdown-item:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Content ─────────────────────────────────────────────────── */
.hms-content { padding: 1.5rem; flex: 1; overflow-y: auto; }

/* ── Cards (Custom — used alongside Tailwind) ───────────────── */
.card {
  background: #1f2937;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}
.card-title { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; color: #f9fafb; }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.08); }
.card-filters { padding: 1rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.08); background: rgba(0,0,0,0.15); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-label {
  display: block; font-size: 0.85rem; font-weight: 600; color: #d1d5db; margin-bottom: 0.375rem;
}
.form-label--required::after { content: ' *'; color: #ef4444; }
.form-input, .form-select {
  width: 100%; padding: 0.625rem 0.875rem;
  background: #111827; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0.5rem; color: #f9fafb;
  font-family: inherit; font-size: 0.875rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
.form-input::placeholder { color: #4b5563; }
.form-input--sm, .form-select.form-input--sm { padding: 0.45rem 0.75rem; font-size: 0.85rem; }
.form-input--error { border-color: #ef4444; }
.form-error { font-size: 0.75rem; color: #ef4444; margin-top: 0.25rem; }
.form-group { margin-bottom: 1rem; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-row-2, .form-row-3 { grid-template-columns: 1fr; } }

.filters-form { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.08); }
.form-section-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 1rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white; font-weight: 600; font-size: 0.875rem;
  border: none; border-radius: 0.5rem; cursor: pointer; text-decoration: none;
  transition: all 150ms ease;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.55); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: rgba(255,255,255,0.08); color: #f9fafb;
  font-weight: 600; font-size: 0.875rem;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 0.5rem; cursor: pointer; text-decoration: none;
  transition: background 150ms ease;
}
.btn-secondary:hover { background: rgba(255,255,255,0.15); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: none; color: #9ca3af;
  font-weight: 500; font-size: 0.875rem;
  border: none; border-radius: 0.5rem; cursor: pointer; text-decoration: none;
  transition: all 150ms ease;
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: #f9fafb; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

/* ── Action Icon Buttons ─────────────────────────────────────── */
.action-buttons { display: flex; gap: 0.5rem; align-items: center; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 0.5rem;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.15); cursor: pointer;
  color: #d1d5db; text-decoration: none;
  transition: all 150ms ease; font-size: 0.875rem;
}
.btn-icon--edit { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.4); color: #60a5fa; }
.btn-icon--edit:hover { background: rgba(59,130,246,0.35); color: white; box-shadow: 0 0 12px rgba(59,130,246,0.5); }
.btn-icon--danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #f87171; }
.btn-icon--danger:hover { background: rgba(239,68,68,0.35); color: white; box-shadow: 0 0 12px rgba(239,68,68,0.5); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.65rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 600;
  background: rgba(255,255,255,0.1); color: #d1d5db;
}
.badge--success { background: rgba(16,185,129,0.2); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.badge--error, .badge--danger { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge--warning { background: rgba(245,158,11,0.2); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge--secondary { background: rgba(255,255,255,0.08); color: #d1d5db; border: 1px solid rgba(255,255,255,0.1); }
.badge--info { background: rgba(6,182,212,0.2); color: #22d3ee; border: 1px solid rgba(6,182,212,0.3); }
.badge--ml { margin-left: 0.5rem; }

/* ── Data Tables ─────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  padding: 0.875rem 1.25rem; text-align: left; font-size: 0.75rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: #9ca3af; background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #d1d5db; vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.user-cell { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar-sm {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white; flex-shrink: 0;
  box-shadow: 0 0 10px rgba(59,130,246,0.3);
}

/* ── Auth Page Helpers ───────────────────────────────────────── */
.auth-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.auth-bg-orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.12;
  animation: orb-float 8s ease-in-out infinite;
}
.auth-bg-orb-1 { width: 600px; height: 600px; background: #3b82f6; top: -200px; left: -200px; }
.auth-bg-orb-2 { width: 400px; height: 400px; background: #6366f1; bottom: -150px; right: -100px; animation-delay: -3s; }
.auth-bg-orb-3 { width: 300px; height: 300px; background: #06b6d4; top: 50%; right: 20%; animation-delay: -6s; }
@keyframes orb-float {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); }
}
.auth-card { animation: auth-card-in 0.4s ease-out; }
@keyframes auth-card-in { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.auth-form-card {
  background: rgba(31,41,55,0.95); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem; padding: 2rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 30px rgba(59,130,246,0.1);
}
.auth-form-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; color: #f9fafb; }
.auth-form-subtitle { color: #9ca3af; text-align: center; font-size: 0.875rem; margin-bottom: 1.75rem; }
.auth-link { color: #3b82f6; text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: color 150ms ease; }
.auth-link:hover { color: #60a5fa; text-decoration: underline; }
.auth-security-note { text-align: center; margin-top: 1.25rem; font-size: 0.75rem; color: #6b7280; }
.auth-alert { padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; }
.auth-alert--success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: #34d399; }

/* ── Dashboard Stat Cards ────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.stat-card {
  background: #1f2937; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem; padding: 1.5rem;
  display: flex; align-items: center; gap: 1.25rem;
  transition: all 200ms ease; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 15px 30px rgba(0,0,0,0.4), 0 0 15px rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.4); }
.stat-icon { width: 3.25rem; height: 3.25rem; border-radius: 0.75rem; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-card--blue .stat-icon { background: rgba(59,130,246,0.15); color: #60a5fa; }
.stat-card--green .stat-icon { background: rgba(16,185,129,0.15); color: #34d399; }
.stat-card--indigo .stat-icon { background: rgba(99,102,241,0.15); color: #818cf8; }
.stat-card--purple .stat-icon { background: rgba(168,85,247,0.15); color: #c084fc; }
.stat-label { font-size: 0.8rem; color: #9ca3af; font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-top: 0.375rem; color: #f9fafb; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.875rem 1rem; border-radius: 0.75rem; margin-bottom: 1rem;
  font-size: 0.875rem; border: 1px solid transparent; position: relative;
}
.alert-dismiss { position: absolute; right: 0.75rem; top: 0.75rem; background: none; border: none; cursor: pointer; opacity: 0.6; padding: 0.125rem; }
.alert-dismiss:hover { opacity: 1; }
.alert--success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.25); color: #34d399; }
.alert--error   { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); color: #f87171; }
.alert--warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.25); color: #fbbf24; }
.alert--info    { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.25); color: #60a5fa; }

/* ── Audit Actions ────────────────────────────────────────────── */
.audit-action { display: inline-flex; align-items: center; padding: 0.125rem 0.5rem; border-radius: 0.375rem; font-size: 0.7rem; font-weight: 600; text-transform: capitalize; }
.audit-action--auth    { background: rgba(6,182,212,0.15); color: #22d3ee; }
.audit-action--danger  { background: rgba(239,68,68,0.15); color: #f87171; }
.audit-action--success { background: rgba(16,185,129,0.15); color: #34d399; }
.audit-action--info    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.audit-action--secondary { background: rgba(255,255,255,0.07); color: #9ca3af; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ── Focus ───────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .hms-sidebar, .hms-header { display: none; }
  .hms-main { margin-left: 0; }
}
