/* ============================================================
   HealthFlow Personal Health OS — Base Styles
   base.css
   ============================================================ */

/* ------------------------------------------------------------
   1. Import Variables
   ------------------------------------------------------------ */
@import './variables.css';

/* ------------------------------------------------------------
   2. Google Fonts — Inter
   ------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

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

html {
  font-size: 16px;
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  tab-size: 4;
}

/* Block elements */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
  display: block;
}

/* Lists */
ul,
ol {
  list-style: none;
  padding-left: 0;
}

/* Embedded content */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* Forms */
input,
button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Tables */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Horizontal rule */
hr {
  height: 0;
  border: none;
  border-top: 1px solid var(--hf-border);
  margin: var(--hf-space-4) 0;
  color: inherit;
}

/* Abbreviations */
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* Code & preformatted */
code,
kbd,
samp,
pre {
  font-family: var(--hf-font-mono, ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace);
  font-size: 0.875em;
}

code {
  background: var(--hf-bg-secondary);
  padding: 0.1em 0.4em;
  border-radius: var(--hf-radius-xs);
  color: var(--hf-primary-dark);
}

pre {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Remove default fieldset styles */
fieldset {
  border: none;
}

/* Hidden attribute */
[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------
   4. Body Base Styles
   ------------------------------------------------------------ */
body {
  font-family: var(--hf-font, 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif);
  font-size: var(--hf-text-base, 1rem);
  font-weight: var(--hf-weight-normal, 400);
  line-height: var(--hf-leading-normal, 1.6);
  color: var(--hf-text, #111827);
  background-color: var(--hf-bg, #f9fafb);
  overflow-x: hidden;
  text-rendering: optimizeSpeed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Smooth transition on theme change */
  transition:
    background-color var(--hf-transition, 0.3s ease),
    color var(--hf-transition, 0.3s ease),
    border-color var(--hf-transition, 0.3s ease);
}

/* ------------------------------------------------------------
   5. Typography — Headings h1–h6
   ------------------------------------------------------------ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--hf-font, 'Inter', sans-serif);
  font-weight: var(--hf-weight-semibold, 600);
  line-height: var(--hf-leading-tight, 1.25);
  color: var(--hf-text, #0f172a);
  letter-spacing: -0.015em;
  margin-bottom: 0;
  transition: color var(--hf-transition, 0.3s ease);
}

h1 {
  font-size: var(--hf-text-4xl, 2.25rem);
  font-weight: var(--hf-weight-bold, 700);
  letter-spacing: -0.025em;
}

h2 {
  font-size: var(--hf-text-3xl, 1.875rem);
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--hf-text-2xl, 1.5rem);
  letter-spacing: -0.015em;
}

h4 {
  font-size: var(--hf-text-xl, 1.25rem);
  letter-spacing: -0.01em;
}

h5 {
  font-size: var(--hf-text-lg, 1.125rem);
  letter-spacing: -0.005em;
}

h6 {
  font-size: var(--hf-text-base, 1rem);
  letter-spacing: 0;
}

p {
  margin-bottom: 0;
  line-height: var(--hf-leading-relaxed, 1.75);
  transition: color var(--hf-transition, 0.3s ease);
}

/* ------------------------------------------------------------
   6. Link Styles
   ------------------------------------------------------------ */
a {
  color: var(--hf-primary, #2563eb);
  text-decoration: none;
  text-underline-offset: 3px;
  transition:
    color var(--hf-transition-fast, 0.15s ease),
    text-decoration-color var(--hf-transition-fast, 0.15s ease),
    opacity var(--hf-transition-fast, 0.15s ease);
}

a:hover {
  color: var(--hf-primary-dark, #1d4ed8);
  text-decoration: underline;
}

a:active {
  opacity: 0.8;
}

a:visited {
  color: var(--hf-primary, #2563eb);
}

/* ------------------------------------------------------------
   7. Image Responsive Defaults
   ------------------------------------------------------------ */
img {
  max-width: 100%;
  height: auto;
  border-style: none;
  vertical-align: middle;
}

video {
  max-width: 100%;
  height: auto;
}

figure {
  margin: 0;
}

figcaption {
  font-size: var(--hf-text-sm, 0.875rem);
  color: var(--hf-text-muted, #6b7280);
  margin-top: var(--hf-space-2, 0.5rem);
  text-align: center;
}

/* ------------------------------------------------------------
   8. Selection Colors
   ------------------------------------------------------------ */
::selection {
  background-color: var(--hf-primary-subtle, rgba(37, 99, 235, 0.15));
  color: var(--hf-primary-dark, #1d4ed8);
  text-shadow: none;
}

::-moz-selection {
  background-color: var(--hf-primary-subtle, rgba(37, 99, 235, 0.15));
  color: var(--hf-primary-dark, #1d4ed8);
  text-shadow: none;
}

/* ------------------------------------------------------------
   9. Focus Outline Styles (Accessibility)
   ------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--hf-primary, #2563eb);
  outline-offset: 2px;
  border-radius: var(--hf-radius-xs, 4px);
}

/* Remove focus ring for mouse/pointer interactions */
:focus:not(:focus-visible) {
  outline: none;
}

/* Button focus enhancement */
button:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--hf-primary, #2563eb);
  outline-offset: 2px;
  border-radius: var(--hf-radius-xs, 4px);
  box-shadow: 0 0 0 4px var(--hf-primary-subtle, rgba(37, 99, 235, 0.2));
}

/* Input / select / textarea focus */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--hf-primary, #2563eb);
  outline-offset: 0;
  border-radius: var(--hf-radius-xs, 4px);
  box-shadow: 0 0 0 3px var(--hf-primary-subtle, rgba(37, 99, 235, 0.15));
}

/* Skip-to-content link */
.hf-skip-link {
  position: absolute;
  top: -100%;
  left: var(--hf-space-4, 1rem);
  z-index: 9999;
  padding: var(--hf-space-2, 0.5rem) var(--hf-space-4, 1rem);
  background-color: var(--hf-primary, #2563eb);
  color: #ffffff;
  font-weight: var(--hf-weight-semibold, 600);
  text-decoration: none;
  border-radius: var(--hf-radius, 6px);
  transition: top 0.2s ease;
}

.hf-skip-link:focus {
  top: var(--hf-space-4, 1rem);
}

/* ------------------------------------------------------------
   10. Reduced Motion Preference
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------
   11. Custom Scrollbar Styles (WebKit)
   ------------------------------------------------------------ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: var(--hf-radius-full, 9999px);
}

::-webkit-scrollbar-thumb {
  background: var(--hf-border, #d1d5db);
  border-radius: var(--hf-radius-full, 9999px);
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--hf-text-muted, #6b7280);
}

::-webkit-scrollbar-thumb:active {
  background: var(--hf-primary, #2563eb);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--hf-border, #d1d5db) transparent;
}

/* ------------------------------------------------------------
   12. Utility Classes
   ------------------------------------------------------------ */

/* Gradient text */
.hf-text-gradient {
  background: var(--hf-gradient-primary, linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #06b6d4 100%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.hf-text-gradient-success {
  background: var(--hf-gradient-success, linear-gradient(135deg, #10b981 0%, #06b6d4 100%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

/* Screen reader only / visually hidden */
.hf-visually-hidden,
.hf-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Focusable visually-hidden — reveals on focus */
.hf-visually-hidden:focus,
.hf-visually-hidden:active,
.hf-sr-only:focus,
.hf-sr-only:active {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* ------------------------------------------------------------
   13. Skeleton Loader with Shimmer Effect
   ------------------------------------------------------------ */
@keyframes hf-shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

.hf-skeleton {
  display: block;
  border-radius: var(--hf-radius-sm, 4px);
  background: linear-gradient(
    90deg,
    var(--hf-bg-secondary, #e2e8f0) 25%,
    var(--hf-bg-tertiary, #f8fafc) 50%,
    var(--hf-bg-secondary, #e2e8f0) 75%
  );
  background-size: 200% 100%;
  animation: hf-shimmer 1.5s ease-in-out infinite;
  transition: background-color var(--hf-transition, 0.3s ease);
}

.hf-skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: var(--hf-radius-xs, 2px);
}

.hf-skeleton-text:last-child {
  width: 75%;
}

.hf-skeleton-circle {
  border-radius: var(--hf-radius-full, 9999px);
}

.hf-skeleton-card {
  height: 160px;
  border-radius: var(--hf-radius, 8px);
}

/* ------------------------------------------------------------
   14. Loading Spinner
   ------------------------------------------------------------ */
@keyframes hf-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.hf-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: hf-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.hf-spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.hf-spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.hf-spinner-xl {
  width: 64px;
  height: 64px;
  border-width: 4px;
}

/* Spinner with track */
.hf-spinner-track {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--hf-primary-subtle, rgba(37, 99, 235, 0.15));
  border-top-color: var(--hf-primary, #2563eb);
  border-radius: 50%;
  animation: hf-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Spinner container helper */
.hf-spinner-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--hf-space-3, 0.75rem);
  padding: var(--hf-space-6, 1.5rem);
}

/* Page loader */
.hf-page-loader {
  padding: var(--hf-space-6, 1.5rem);
}

.hf-page-loader .hf-skeleton-card + .hf-skeleton-card {
  margin-top: var(--hf-space-4, 1rem);
}

/* ------------------------------------------------------------
   15. Print Media Query
   ------------------------------------------------------------ */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    background: #ffffff !important;
    color: #000000 !important;
    transition: none !important;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    orphans: 3;
    widows: 3;
    color: #000000 !important;
    transition: none !important;
  }

  h1 { font-size: 22pt; }
  h2 { font-size: 18pt; }
  h3 { font-size: 14pt; }
  h4 { font-size: 12pt; }

  p,
  blockquote,
  ul,
  ol,
  dl {
    orphans: 3;
    widows: 3;
  }

  a,
  a:visited {
    color: #000000 !important;
    text-decoration: underline;
  }

  a[href]::after {
    content: ' (' attr(href) ')';
    font-size: 0.75em;
    color: #555555 !important;
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: '';
  }

  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  table {
    border-collapse: collapse !important;
  }

  table td,
  table th {
    border: 1px solid #cccccc !important;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  /* Hide non-essential UI */
  .hf-sidebar,
  .hf-header,
  .hf-fab,
  .hf-fab-menu,
  .hf-toast-container,
  .hf-spinner,
  .hf-skeleton,
  nav,
  [aria-hidden="true"] {
    display: none !important;
  }

  .hf-main {
    margin-left: 0 !important;
    padding-top: 20px;
  }

  /* Reset gradient text for print */
  .hf-text-gradient,
  .hf-text-gradient-success {
    -webkit-text-fill-color: #000000 !important;
    background: none !important;
    color: #000000 !important;
  }

  ::-webkit-scrollbar {
    display: none;
  }

  @page {
    margin: 1.5cm 2cm;
  }
}
