/**
 * Pulmo 2.0 - Base Styles
 * Estilos fundamentais da aplicação
 */

/* ========================================
   BODY & HTML
   ======================================== */

html {
  font-size: 16px;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background-color: var(--color-background-light);
  overflow-x: hidden;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

/* Force white headings in dark theme */
body:not([data-theme="light"]) h1,
body:not([data-theme="light"]) h2,
body:not([data-theme="light"]) h3,
body:not([data-theme="light"]) h4,
body:not([data-theme="light"]) h5,
body:not([data-theme="light"]) h6 {
  color: #ffffff;
}

h1 {
  font-size: var(--font-size-4xl);
  line-height: var(--line-height-tight);
}

h2 {
  font-size: var(--font-size-3xl);
  line-height: var(--line-height-tight);
}

h3 {
  font-size: var(--font-size-2xl);
  line-height: var(--line-height-base);
}

h4 {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-base);
}

h5 {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-base);
}

h6 {
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

@media (max-width: 768px) {
  h1 { font-size: var(--font-size-3xl); }
  h2 { font-size: var(--font-size-2xl); }
  h3 { font-size: var(--font-size-xl); }
}

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

strong, b {
  font-weight: var(--font-weight-bold);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
}

/* Links */
a {
  color: var(--color-primary);
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ========================================
   LAYOUT CONTAINERS
   ======================================== */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 var(--space-8);
  }
}

.container--sm { max-width: var(--container-sm); }
.container--md { max-width: var(--container-md); }
.container--lg { max-width: var(--container-lg); }
.container--xl { max-width: var(--container-xl); }
.container--full { max-width: 100%; }

/* ========================================
   APP LAYOUT
   ======================================== */

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app__header {
  position: sticky;
  top: 0;
  z-index: var(--z-index-sticky);
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
}

.app__main {
  flex: 1;
  padding: var(--space-6) 0;
}

@media (max-width: 768px) {
  .app__main {
    padding: var(--space-4) 0;
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
  }
}

.app__footer {
  background: var(--color-background);
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-6) 0;
}

/* ========================================
   GRID SYSTEM
   ======================================== */

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--2 {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.grid--4 {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

@media (min-width: 768px) {
  .grid {
    gap: var(--space-6);
  }
  
  .grid--2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid--3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========================================
   FLEXBOX UTILITIES
   ======================================== */

.flex {
  display: flex;
}

.flex--wrap {
  flex-wrap: wrap;
}

.flex--column {
  flex-direction: column;
}

.flex--center {
  align-items: center;
  justify-content: center;
}

.flex--between {
  justify-content: space-between;
}

.flex--around {
  justify-content: space-around;
}

.flex--evenly {
  justify-content: space-evenly;
}

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

.gap--xs { gap: var(--space-xs); }
.gap--sm { gap: var(--space-sm); }
.gap--md { gap: var(--space-md); }
.gap--lg { gap: var(--space-lg); }
.gap--xl { gap: var(--space-xl); }

/* ========================================
   SECTIONS
   ======================================== */

.section {
  padding: var(--space-12) 0;
}

.section--sm {
  padding: var(--space-8) 0;
}

.section--lg {
  padding: var(--space-16) 0;
}

@media (max-width: 768px) {
  .section { padding: var(--space-8) 0; }
  .section--sm { padding: var(--space-6) 0; }
  .section--lg { padding: var(--space-12) 0; }
}

.section__header {
  margin-bottom: var(--space-8);
  text-align: center;
}

.section__title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.section__subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ========================================
   CARDS
   ======================================== */

.card {
  background: var(--color-background);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-md);
  padding: var(--card-padding);
  transition: all var(--transition-base);
  border: 1px solid transparent;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--color-border-light);
}

.card--flat {
  box-shadow: none;
  border: 1px solid var(--color-border-light);
}

.card--ghost {
  background: transparent;
  box-shadow: none;
}

.card__header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.card__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}

.card__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.card__body {
  margin-bottom: var(--space-4);
}

.card__footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ========================================
   IMAGES
   ======================================== */

.img-fluid {
  max-width: 100%;
  height: auto;
}

.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-contain {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.img-rounded {
  border-radius: var(--radius-md);
}

.img-circle {
  border-radius: var(--radius-full);
}

/* ========================================
   ASPECT RATIOS
   ======================================== */

.aspect-square { aspect-ratio: 1 / 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-portrait { aspect-ratio: 3 / 4; }
.aspect-wide { aspect-ratio: 21 / 9; }

/* ========================================
   SCROLL BEHAVIOR
   ======================================== */

.scroll-smooth {
  scroll-behavior: smooth;
}

.overflow-auto {
  overflow: auto;
}

.overflow-hidden {
  overflow: hidden;
}

.overflow-scroll {
  overflow: scroll;
}

.overflow-x-auto {
  overflow-x: auto;
  overflow-y: hidden;
}

.overflow-y-auto {
  overflow-x: hidden;
  overflow-y: auto;
}

/* ========================================
   VISIBILITY & DISPLAY
   ======================================== */

.hidden {
  display: none !important;
}

.visible {
  visibility: visible;
}

.invisible {
  visibility: hidden;
}

@media (max-width: 640px) {
  .hidden-mobile { display: none !important; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .hidden-tablet { display: none !important; }
}

@media (min-width: 1025px) {
  .hidden-desktop { display: none !important; }
}

/* ========================================
   LOADING STATES
   ======================================== */

.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

/* ========================================
   DISABLED STATE
   ======================================== */

.disabled,
[disabled] {
  opacity: var(--opacity-disabled);
  cursor: not-allowed !important;
  pointer-events: none;
}

/* ========================================
   FOCUS STYLES
   ======================================== */

.focus-visible:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

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

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

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

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fadeIn { animation: fadeIn var(--transition-base); }
.animate-fadeOut { animation: fadeOut var(--transition-base); }
.animate-slideInUp { animation: slideInUp var(--transition-base); }
.animate-slideInDown { animation: slideInDown var(--transition-base); }
.animate-zoomIn { animation: zoomIn var(--transition-base); }

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  body {
    background: white;
  }
  
  .no-print {
    display: none !important;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

