/* ═══════════════════════════════════════════════════════════════
   Holter Monitoring – Premium Medical SaaS CSS
   Blue & White theme — responsive sidebar layout
   ═══════════════════════════════════════════════════════════════ */

/* ── Fonts & Reset ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f0f4ff;
  color: #1a2340;
  min-height: 100vh;
}

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --topnav-h: 64px;

  --blue-primary: #1a4d8f;
  --blue-dark: #0f2f5a;
  --blue-light: #3b82f6;
  --blue-lighter: #eff6ff;
  --accent-teal: #0ea5e9;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-red: #ef4444;

  --bg-page: #f0f4ff;
  --bg-white: #ffffff;
  --border: #e5eaf5;
  --shadow-sm: 0 1px 4px rgba(26, 77, 143, .08);
  --shadow-md: 0 4px 16px rgba(26, 77, 143, .12);
  --shadow-lg: 0 8px 32px rgba(26, 77, 143, .16);

  --radius: 12px;
  --radius-sm: 8px;
  --transition: .2s ease;
}

/* ── Layout ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--blue-dark);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width var(--transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .1) transparent;
}

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* Sidebar collapsed state */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .main-wrapper {
  margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .sidebar-nav .nav-link span,
body.sidebar-collapsed .user-meta,
body.sidebar-collapsed .btn-logout span {
  display: none;
}

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px;
}

/* ── Sidebar Brand ──────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  display: block;
}

.brand-tagline {
  color: rgba(255, 255, 255, .5);
  font-size: 11px;
  display: block;
}

/* ── Sidebar Nav ────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, .35);
  padding: 14px 10px 4px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, .35), rgba(14, 165, 233, .25));
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, .25);
}

/* ── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  background: rgba(0, 0, 0, .2);
}

.avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-meta {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  background: rgba(59, 130, 246, .35);
  color: #93c5fd;
  border: none;
  padding: 1px 6px;
  border-radius: 4px;
}

.btn-logout {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .5);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, .2);
  color: #f87171;
}

/* ── Top Nav ────────────────────────────────────────────────── */
.top-nav {
  height: var(--topnav-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--blue-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.sidebar-toggle:hover {
  background: var(--blue-lighter);
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue-dark);
}

.top-nav-right {
  margin-left: auto;
  color: #64748b;
  font-size: 13px;
}

/* ── Flash Messages ─────────────────────────────────────────── */
.flash-wrapper {
  padding: 12px 24px 0;
}

.flash-alert {
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

/* ── Card Panel ─────────────────────────────────────────────── */
.card-panel {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h5,
.panel-header h6 {
  font-weight: 700;
  color: var(--blue-dark);
  margin: 0;
  font-size: 15px;
}

.card-panel .table {
  margin-bottom: 0;
}

.card-panel .table-responsive {
  padding: 0 4px;
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-lg);
}

.stat-blue {
  border-left-color: var(--blue-light);
}

.stat-green {
  border-left-color: var(--accent-green);
}

.stat-orange {
  border-left-color: var(--accent-orange);
}

.stat-purple {
  border-left-color: var(--accent-purple);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: transform 0.3s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(5deg);
}

.stat-blue .stat-icon {
  background: rgba(59, 130, 246, .12);
  color: var(--blue-light);
}

.stat-green .stat-icon {
  background: rgba(16, 185, 129, .12);
  color: var(--accent-green);
}

.stat-orange .stat-icon {
  background: rgba(245, 158, 11, .12);
  color: var(--accent-orange);
}

.stat-purple .stat-icon {
  background: rgba(139, 92, 246, .12);
  color: var(--accent-purple);
}

.stat-label {
  font-size: 12px;
  color: #64748b;
  margin: 0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue-dark);
  margin: 0;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-head th {
  background: var(--blue-lighter);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
  padding: 12px 16px;
}

.table td {
  padding: 12px 16px;
  font-size: 14px;
  border-color: var(--border);
  vertical-align: middle;
  transition: background 0.2s;
}

.table tbody tr {
  transition: transform 0.2s, box-shadow 0.2s;
}

.table tbody tr:hover {
  background: var(--blue-lighter);
}

.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.4);
}

/* ── Ranking List ───────────────────────────────────────────── */
.ranking-list {
  padding: 8px 16px 16px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.ranking-item:last-child {
  border-bottom: none;
}

.rank-num {
  width: 28px;
  height: 28px;
  background: var(--blue-lighter);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-primary);
  flex-shrink: 0;
}

.rank-info {
  flex: 1;
}

.rank-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-dark);
}

.rank-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-light);
  white-space: nowrap;
}

/* ── Detail List ────────────────────────────────────────────── */
.detail-list {
  list-style: none;
  padding: 12px 20px;
  margin: 0;
}

.detail-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-list li:last-child {
  border-bottom: none;
}

.detail-list li span {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.detail-list li strong {
  font-weight: 600;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.form-label.required::after {
  content: ' *';
  color: var(--accent-red);
}

.form-control,
.form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  padding: 9px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.section-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--blue-primary);
  font-weight: 700;
  padding: 10px 0 6px;
  border-bottom: 2px solid var(--blue-lighter);
  margin-bottom: 16px;
}

/* ── Auth Layout ────────────────────────────────────────────── */
.auth-body {
  background: none;
  min-height: 100vh;
}

.auth-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2f5a 0%, #1a4d8f 40%, #0ea5e9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.auth-card {
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--blue-primary), var(--accent-teal));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(26, 77, 143, .35);
}

.auth-brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--blue-dark);
  margin: 0;
}

.auth-tagline {
  font-size: 13px;
  color: #64748b;
  margin: 4px 0 0;
}

.auth-footer {
  text-align: center;
  color: rgba(255, 255, 255, .6);
  font-size: 12px;
  margin-top: 20px;
}

.btn-login {
  height: 48px;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

.patient-link {
  font-size: 13px;
  color: var(--blue-primary);
  text-decoration: none;
}

.patient-link:hover {
  text-decoration: underline;
}

.pwd-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
}

.otp-input {
  font-size: 28px;
  text-align: center;
  letter-spacing: 10px;
  font-weight: 700;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--blue-primary), var(--blue-light));
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue-primary));
}

/* ── Upload Zone ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--blue-light);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  background: var(--blue-lighter);
  transition: all var(--transition);
}

.upload-zone:hover,
.upload-zone.drag-over {
  background: rgba(59, 130, 246, .1);
  border-color: var(--blue-primary);
}

/* ── Report Box ─────────────────────────────────────────────── */
.report-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
}

.report-success-card,
.report-pending-card {
  padding: 40px 20px;
}

.report-icon {
  font-size: 56px;
  margin-bottom: 20px;
  color: var(--blue-primary);
}

/* ── QR Alert ───────────────────────────────────────────────── */
.qr-alert {
  display: flex;
  align-items: center;
  background: var(--blue-lighter);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 16px;
}

.qr-img {
  max-width: 150px;
  border-radius: 8px;
}

/* ── Diary ──────────────────────────────────────────────────── */
.diary-entry {
  border-left: 3px solid var(--blue-light);
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--blue-lighter);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.diary-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 6px;
}

.diary-date,
.diary-time {
  font-size: 12px;
  color: var(--blue-primary);
  font-weight: 600;
}

.diary-row {
  font-size: 13px;
  margin-bottom: 3px;
}

/* ── Rankings ───────────────────────────────────────────────── */
.rank-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
}

.rank-badge.gold {
  background: #fef3c7;
  color: #92400e;
}

.rank-badge.silver {
  background: #f1f5f9;
  color: #475569;
}

.rank-badge.bronze {
  background: #fdf4ff;
  color: #7c3aed;
}

/* ── Misc ───────────────────────────────────────────────────── */
.doctor-id {
  font-size: 13px;
  background: var(--blue-lighter);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--blue-primary);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .stat-value {
    font-size: 20px;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 16px;
  }

  .auth-card {
    padding: 28px 22px;
  }
}