/* ============================================================
   CLINICORP APPOINTMENTS — Design System (GoHighLevel style)
   ============================================================ */

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

:root {
  --blue:        #0085FF;
  --blue-hover:  #006EDB;
  --blue-light:  #EBF4FF;
  --blue-pale:   #F0F7FF;
  --red:         #F04438;
  --red-light:   #FEF3F2;
  --red-hover:   #D92D20;
  --green:       #12B76A;
  --green-light: #ECFDF3;
  --gray-900:    #101828;
  --gray-700:    #344054;
  --gray-500:    #667085;
  --gray-400:    #98A2B3;
  --gray-300:    #D0D5DD;
  --gray-200:    #EAECF0;
  --gray-100:    #F2F4F7;
  --gray-50:     #F9FAFB;
  --white:       #FFFFFF;
  --shadow-xs:   0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm:   0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md:   0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg:   0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --transition:  0.18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--gray-700);
  background: var(--gray-50);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}



.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--blue);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}

.logo-icon svg { display: block; }

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.2px;
}

.logo-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-500);
  display: block;
  margin-top: -2px;
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 100px;
  padding: 5px 12px 5px 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---- Main content ---- */
.app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.page { width: 100%; display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  overflow: hidden;
}

.auth-banner {
  background: linear-gradient(135deg, #0085FF 0%, #0057B0 100%);
  padding: 32px 32px 24px;
  color: white;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-banner-icon {
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}

.auth-banner-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.auth-banner h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.auth-banner p {
  font-size: 13.5px;
  opacity: 0.85;
  line-height: 1.55;
}

.auth-body { padding: 28px 32px 32px; }

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

/* --- Phone field with country picker --- */
.phone-field-wrapper {
  display: flex;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  overflow: visible;
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
}

.phone-field-wrapper:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 133, 255, 0.12);
}

.country-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border: none;
  border-right: 1.5px solid var(--gray-300);
  background: var(--gray-50);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  border-radius: 0;
  transition: background var(--transition);
  flex-shrink: 0;
}

.country-btn:hover { background: var(--gray-100); }

.country-flag { font-size: 18px; line-height: 1; }
.country-ddi  { font-size: 13px; }
.country-chevron { font-size: 10px; color: var(--gray-400); }

/* Country dropdown */
.country-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 200;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 300px;
  max-height: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: dropdownOpen 0.15s ease;
}

.country-dropdown.hidden { display: none; }

@keyframes dropdownOpen {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.country-search {
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: var(--gray-900);
}

.country-list {
  overflow-y: auto;
  flex: 1;
}

.country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}

.country-item:hover { background: var(--gray-50); }
.country-item.selected { background: var(--blue-pale); color: var(--blue); font-weight: 500; }

.ci-flag { display:flex; align-items:center; flex-shrink: 0; }
.ci-flag img { border-radius: 2px; display: block; }
.ci-name { flex: 1; color: var(--gray-700); }
.ci-code { color: var(--gray-400); font-size: 12px; flex-shrink: 0; }

.phone-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: transparent;
  min-width: 0;
}

.phone-input::placeholder { color: var(--gray-400); }

/* --- Standard input --- */
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 133, 255, 0.12);
}

.form-input::placeholder { color: var(--gray-400); }
.form-input.error { border-color: var(--red); }
.form-input.error:focus { box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.12); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--blue);
  color: white;
  box-shadow: 0 1px 2px rgba(0, 133, 255, 0.3);
}
.btn-primary:hover { background: var(--blue-hover); box-shadow: 0 4px 12px rgba(0, 133, 255, 0.35); }

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger {
  background: var(--white);
  color: var(--red);
  border: 1.5px solid var(--gray-300);
}
.btn-danger:hover { background: var(--red-light); border-color: var(--red); }

.btn-full { width: 100%; }

.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Loading spinner inside button */
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}
.btn.loading .btn-spinner { display: block; }
.btn.loading .btn-text { display: none; }

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

/* Alert / error message */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease;
}

.alert-error   { background: var(--red-light);   color: #9D1B1B; border: 1px solid #FEE4E2; }
.alert-success { background: var(--green-light);  color: #076347; border: 1px solid #D1FAE5; }
.alert-info    { background: var(--blue-pale);    color: #0057B0; border: 1px solid #D1E9FF; }

.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   APPOINTMENTS PAGE
   ============================================================ */
.appts-layout {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.appts-header {
  margin-bottom: 28px;
}

.appts-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.appts-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.4px;
}

.appts-subtitle {
  font-size: 13.5px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Patient info badge */
.patient-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}

.patient-avatar-lg {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #006EDB);
  color: white;
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.patient-contact { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Appointments list */
.appts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Appointment card */
.appt-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  animation: cardIn 0.3s ease backwards;
}

.appt-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.appt-card-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
}

/* Card left: details */
.appt-details {
  padding: 20px 20px 20px 24px;
  border-right: 1px solid var(--gray-100);
}

.appt-type-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.appt-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.2px;
  margin-bottom: 12px;
}

.appt-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.appt-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600, #475467);
}

.appt-meta-icon {
  width: 16px; height: 16px;
  color: var(--gray-400);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.appt-meta-row strong { color: var(--gray-700); font-weight: 500; }

.appt-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--green-light);
  color: var(--green);
  margin-top: 12px;
}

.appt-status-badge.badge-neutral {
  background: var(--gray-100);
  color: var(--gray-700);
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Card right: actions */
.appt-actions {
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  min-width: 148px;
}

/* Empty state */
.empty-state {
  background: var(--white);
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius-xl);
  padding: 56px 32px;
  text-align: center;
  color: var(--gray-500);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.empty-desc { font-size: 13.5px; line-height: 1.6; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .app-main { padding: 20px 12px; }

  .auth-banner { padding: 24px 20px 18px; }
  .auth-body   { padding: 22px 20px 24px; }

  .appt-card-inner { grid-template-columns: 1fr; }
  .appt-details { border-right: none; border-bottom: 1px solid var(--gray-100); }
  .appt-actions {
    flex-direction: row;
    min-width: auto;
    padding: 14px 20px;
    gap: 8px;
  }
  .appt-actions .btn { flex: 1; font-size: 13px; }

  .appts-header-top { flex-direction: column; }
  .appts-title { font-size: 19px; }

  .country-dropdown { width: 280px; }
}
