/* ================================================================
   PhysioSaaS — Global Stylesheet
   All colors use CSS variables injected by BrandingHelper.
   No hardcoded brand colors anywhere in this file.
================================================================ */

/* ── Google Fonts base import (Poppins as safe default) ── */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* These are overridden per-clinic by BrandingHelper::injectCSS() */
  --primary:       #0f766e;
  --primary-light: #ccfbf1;
  --secondary:     #134e4a;
  --accent:        #14b8a6;
  --accent-light:  #d1faf5;
  --sidebar:       #0a2e2a;
  --font:          'Poppins', sans-serif;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Status */
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #3b82f6;

  /* Surfaces */
  --surface:        #ffffff;
  --surface-2:      var(--gray-50);
  --border:         var(--gray-200);
  --text:           var(--gray-800);
  --text-muted:     var(--gray-500);

  /* Sizing */
  --sidebar-w:      260px;
  --header-h:       64px;
  --radius:         10px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.14);

  /* Transitions */
  --ease:           cubic-bezier(.4,0,.2,1);
  --duration:       200ms;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family:    var(--font);
  color:          var(--text);
  background:     var(--gray-50);
  line-height:    1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--duration) var(--ease); }
a:hover { color: var(--accent); }

img { max-width: 100%; display: block; }

/* ================================================================
   Typography
================================================================ */
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.3; color: var(--gray-900); }
h1 { font-size: clamp(1.75rem, 3vw, 2.5rem); }
h2 { font-size: clamp(1.4rem,  2.5vw, 2rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.text-muted    { color: var(--text-muted); }
.text-primary  { color: var(--primary); }
.text-accent   { color: var(--accent); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }

/* ================================================================
   Layout — Sidebar + Main
================================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width:       var(--sidebar-w);
  background:  var(--sidebar);
  position:    fixed;
  top:         0; left: 0; bottom: 0;
  overflow-y:  auto;
  overflow-x:  hidden;
  z-index:     100;
  transition:  width var(--duration) var(--ease);
  display:     flex;
  flex-direction: column;
}

.sidebar-brand {
  padding:     1.5rem 1.25rem 1rem;
  display:     flex;
  align-items: center;
  gap:         .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand img {
  width:  40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(255,255,255,.12);
  padding: 4px;
}

.sidebar-brand-text {
  flex: 1;
}

.sidebar-brand-name {
  font-size:   .95rem;
  font-weight: 700;
  color:       #fff;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-tagline {
  font-size:   .7rem;
  color:       rgba(255,255,255,.5);
  margin-top:  1px;
}

.sidebar-nav {
  padding:  .75rem 0;
  flex:     1;
}

.sidebar-section {
  padding:    .5rem 1.25rem .25rem;
  font-size:  .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color:      rgba(255,255,255,.35);
}

.sidebar-link {
  display:     flex;
  align-items: center;
  gap:         .75rem;
  padding:     .6rem 1.25rem;
  color:       rgba(255,255,255,.7);
  font-size:   .875rem;
  font-weight: 500;
  border-radius: 0;
  transition:  all var(--duration) var(--ease);
  position:    relative;
}

.sidebar-link:hover {
  color:       #fff;
  background:  rgba(255,255,255,.08);
}

.sidebar-link.active {
  color:       #fff;
  background:  rgba(255,255,255,.12);
  font-weight: 600;
}

.sidebar-link.active::before {
  content:    '';
  position:   absolute;
  left:       0; top: 0; bottom: 0;
  width:      3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-link svg { opacity: .7; flex-shrink: 0; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }

/* Main content area */
.main-content {
  margin-left: var(--sidebar-w);
  flex:        1;
  display:     flex;
  flex-direction: column;
  min-height:  100vh;
}

/* Top Header */
.app-header {
  height:       var(--header-h);
  background:   var(--surface);
  border-bottom: 1px solid var(--border);
  display:      flex;
  align-items:  center;
  padding:      0 1.5rem;
  gap:          1rem;
  position:     sticky;
  top:          0;
  z-index:      50;
}

.header-title {
  font-size:   1.05rem;
  font-weight: 600;
  flex:        1;
}

.header-actions {
  display:     flex;
  align-items: center;
  gap:         .75rem;
}

.header-avatar {
  width:        36px;
  height:       36px;
  border-radius: 50%;
  background:   var(--primary);
  color:        #fff;
  display:      flex;
  align-items:  center;
  justify-content: center;
  font-size:    .85rem;
  font-weight:  600;
  cursor:       pointer;
}

/* Page content */
.page-content {
  padding: 1.75rem 2rem;
  flex:    1;
}

.page-header {
  display:     flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap:   wrap;
  gap:         .75rem;
}

.page-title { font-size: 1.4rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: .875rem; margin-top: .2rem; }

/* ================================================================
   Cards
================================================================ */
.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       1.5rem;
  box-shadow:    var(--shadow-sm);
  transition:    box-shadow var(--duration) var(--ease);
}

.card:hover { box-shadow: var(--shadow); }
.card-header { padding-bottom: 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.card-title  { font-size: 1rem; font-weight: 600; }

/* Stat Cards & Grid Layouts */
.stats-row { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
  gap: 1.25rem; 
}

.stat-card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       1.25rem 1.5rem;
  display:       flex;
  align-items:   center;
  gap:           1rem;
  box-shadow:    var(--shadow-sm);
  transition:    transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

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

.stat-icon {
  width:         52px;
  height:        52px;
  border-radius: var(--radius);
  display:       flex;
  align-items:   center;
  justify-content: center;
  flex-shrink:   0;
  font-size:     1.4rem;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.accent  { background: var(--accent-light);  color: var(--accent); }
.stat-icon.success { background: #d1fae5; color: var(--success); }
.stat-icon.warning { background: #fef3c7; color: var(--warning); }
.stat-icon.danger  { background: #fee2e2; color: var(--danger); }

.stat-body { flex: 1; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; font-weight: 500; }

/* ================================================================
   Buttons
================================================================ */
.btn {
  display:       inline-flex;
  align-items:   center;
  gap:           .4rem;
  padding:       .55rem 1.2rem;
  font-family:   var(--font);
  font-size:     .875rem;
  font-weight:   600;
  border-radius: var(--radius);
  border:        1.5px solid transparent;
  cursor:        pointer;
  transition:    all var(--duration) var(--ease);
  text-decoration: none;
  white-space:   nowrap;
}

.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--primary);
  color:      #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--secondary); border-color: var(--secondary); color:#fff; transform: translateY(-1px); }

.btn-accent {
  background: var(--accent);
  color:      #fff;
  border-color: var(--accent);
}
.btn-accent:hover { opacity: .9; color:#fff; transform: translateY(-1px); }

.btn-outline {
  background:  transparent;
  color:       var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-ghost {
  background:  transparent;
  color:       var(--gray-600);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }

.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-lg { padding: .8rem 2rem;   font-size: 1rem; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }

/* ================================================================
   Forms
================================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display:     block;
  font-size:   .85rem;
  font-weight: 600;
  color:       var(--gray-700);
  margin-bottom: .4rem;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  display:      block;
  width:        100%;
  padding:      .6rem .85rem;
  font-family:  var(--font);
  font-size:    .9rem;
  color:        var(--text);
  background:   var(--surface);
  border:       1.5px solid var(--border);
  border-radius: var(--radius);
  transition:   border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  outline:      none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow:   0 0 0 3px rgba(15,118,110,.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.12); }

.form-error {
  font-size:  .78rem;
  color:      var(--danger);
  margin-top: .3rem;
  display:    flex;
  align-items: center;
  gap:        .3rem;
}

.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn           { border-radius: 0 var(--radius) var(--radius) 0; }

/* ================================================================
   Badges & Status
================================================================ */
.badge {
  display:       inline-flex;
  align-items:   center;
  gap:           .3rem;
  padding:       .2rem .65rem;
  border-radius: 999px;
  font-size:     .72rem;
  font-weight:   600;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.badge-active    { background: #d1fae5; color: #065f46; }
.badge-trial     { background: #dbeafe; color: #1e40af; }
.badge-pending   { background: #fef9c3; color: #92400e; }
.badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-primary   { background: var(--primary-light); color: var(--primary); }

/* ================================================================
   Table
================================================================ */
.table-wrapper {
  overflow-x: auto;
  border:     1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

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

.table thead th {
  background:    var(--gray-50);
  color:         var(--gray-600);
  font-weight:   600;
  font-size:     .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding:       .85rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space:   nowrap;
}

.table tbody td {
  padding:     .85rem 1rem;
  border-bottom: 1px solid var(--border);
  color:       var(--text);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

/* ================================================================
   Alerts & Flash Messages
================================================================ */
.alert {
  padding:      .85rem 1.1rem;
  border-radius: var(--radius);
  font-size:    .875rem;
  display:      flex;
  align-items:  flex-start;
  gap:          .6rem;
  margin-bottom: 1rem;
  border:       1px solid transparent;
}

.alert-success { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }
.alert-error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

/* ================================================================
   Auth Layout (centered cards)
================================================================ */
.auth-layout {
  min-height:   100vh;
  display:      flex;
  align-items:  center;
  justify-content: center;
  background:   linear-gradient(135deg, var(--secondary) 0%, var(--primary) 50%, var(--accent) 100%);
  padding:      2rem;
}

.auth-card {
  background:    #fff;
  border-radius: var(--radius-lg);
  box-shadow:    var(--shadow-lg);
  width:         100%;
  max-width:     480px;
  padding:       2.5rem;
  animation:     fadeUp .35s var(--ease) both;
}

.auth-logo {
  text-align:  center;
  margin-bottom: 1.75rem;
}

.auth-logo img {
  height:      56px;
  margin:      0 auto .75rem;
}

.auth-title {
  font-size:   1.4rem;
  font-weight: 700;
  text-align:  center;
  color:       var(--gray-900);
}

.auth-subtitle {
  text-align:  center;
  color:       var(--text-muted);
  font-size:   .875rem;
  margin-top:  .4rem;
}

/* ================================================================
   Registration Wizard Progress
================================================================ */
.wizard-progress {
  display:       flex;
  gap:           0;
  margin-bottom: 2.5rem;
  position:      relative;
}

.wizard-progress::before {
  content:    '';
  position:   absolute;
  top:        18px;
  left:       12%;
  right:      12%;
  height:     2px;
  background: var(--gray-200);
  z-index:    0;
}

.wizard-step {
  flex:           1;
  text-align:     center;
  position:       relative;
  z-index:        1;
}

.wizard-step-dot {
  width:          36px;
  height:         36px;
  border-radius:  50%;
  background:     var(--gray-200);
  color:          var(--gray-500);
  display:        flex;
  align-items:    center;
  justify-content: center;
  font-size:      .85rem;
  font-weight:    700;
  margin:         0 auto .5rem;
  transition:     all var(--duration) var(--ease);
}

.wizard-step.done .wizard-step-dot   { background: var(--success); color: #fff; }
.wizard-step.active .wizard-step-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-light); }

.wizard-step-label {
  font-size:  .72rem;
  color:      var(--text-muted);
  font-weight: 500;
}

.wizard-step.active .wizard-step-label { color: var(--primary); font-weight: 600; }

/* ================================================================
   Plan Cards
================================================================ */
.plan-cards {
  display:     grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:         1rem;
}

.plan-card {
  border:       2px solid var(--border);
  border-radius: var(--radius-lg);
  padding:      1.5rem;
  cursor:       pointer;
  transition:   all var(--duration) var(--ease);
  position:     relative;
  text-align:   center;
}

.plan-card:hover {
  border-color: var(--primary);
  transform:    translateY(-3px);
  box-shadow:   var(--shadow);
}

.plan-card.selected {
  border-color: var(--primary);
  background:   var(--primary-light);
  box-shadow:   0 0 0 3px var(--primary-light);
}

.plan-card-badge {
  position:    absolute;
  top:         -10px;
  left:        50%;
  transform:   translateX(-50%);
  padding:     .2rem .85rem;
  border-radius: 999px;
  font-size:   .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background:  var(--primary);
  color:       #fff;
}

.plan-price {
  font-size:   2rem;
  font-weight: 800;
  color:       var(--gray-900);
  line-height: 1;
}

.plan-price sup { font-size: 1rem; vertical-align: super; }
.plan-price span { font-size: .875rem; font-weight: 400; color: var(--text-muted); }

.plan-features {
  list-style:  none;
  text-align:  left;
  margin-top:  1rem;
  font-size:   .82rem;
}

.plan-features li {
  display:     flex;
  gap:         .5rem;
  padding:     .3rem 0;
  color:       var(--gray-600);
}

.plan-features li::before {
  content:  '✓';
  color:    var(--success);
  font-weight: 700;
  flex-shrink: 0;
}

/* ================================================================
   Color Picker + Live Preview
================================================================ */
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.color-swatch-picker {
  display:     flex;
  align-items: center;
  gap:         .75rem;
  border:      1.5px solid var(--border);
  border-radius: var(--radius);
  padding:     .5rem .75rem;
  cursor:      pointer;
  transition:  border-color var(--duration) var(--ease);
}

.color-swatch-picker:hover { border-color: var(--primary); }

.color-swatch {
  width:        32px;
  height:       32px;
  border-radius: 6px;
  flex-shrink:  0;
  border:       1px solid rgba(0,0,0,.1);
}

.color-swatch-picker input[type="color"] {
  position: absolute;
  opacity:  0;
  width:    0;
  height:   0;
}

/* ================================================================
   Grid utilities
================================================================ */
.row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; }
.col-2 { flex: 2; }
.col-3 { flex: 3; }
.col-auto { flex: 0 0 auto; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar       { transform: translateX(-100%); }
  .main-content  { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content  { padding: 1rem; }
}

/* ================================================================
   Utilities
================================================================ */
.mt-0 { margin-top: 0; }       .mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }    .mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }    .mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex    { display: flex; }
.d-grid    { display: grid; }
.d-none    { display: none; }
.d-block   { display: block; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.gap-3  { gap: 1.5rem; }
.flex-1 { flex: 1; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }
.fs-sm       { font-size: .83rem; }

.w-100 { width: 100%; }
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: 999px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ================================================================
   Animations
================================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

.animate-fade-up { animation: fadeUp .35s var(--ease) both; }
.animate-fade-in { animation: fadeIn .3s var(--ease) both; }

.spinner {
  width:  20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

/* ================================================================
   Pagination
================================================================ */
.pagination {
  display:    flex;
  gap:        .35rem;
  margin-top: 1.25rem;
  align-items: center;
}

.page-link {
  padding:      .4rem .75rem;
  border-radius: var(--radius);
  border:       1px solid var(--border);
  font-size:    .85rem;
  color:        var(--gray-600);
  background:   var(--surface);
  transition:   all var(--duration) var(--ease);
  cursor:       pointer;
}

.page-link:hover, .page-link.active {
  background:  var(--primary);
  border-color: var(--primary);
  color:       #fff;
}

/* ================================================================
   Misc
================================================================ */
.empty-state {
  text-align: center;
  padding:    3rem 1rem;
}
.empty-state-icon { font-size: 3rem; margin-bottom: .75rem; opacity: .4; }
.empty-state-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-700); }
.empty-state-text  { color: var(--text-muted); font-size: .875rem; margin-top: .4rem; }

.breadcrumb {
  display:    flex;
  gap:        .4rem;
  align-items: center;
  font-size:  .825rem;
  color:      var(--text-muted);
  margin-bottom: .75rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { opacity: .5; }
