/* =============================================================
   HCP Gestão — Design System CSS
   Variáveis, utilitários e componentes reutilizáveis
   Apenas design e responsividade — sem lógica funcional
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600&family=Poppins:wght@600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

/* =============================================================
   1. CSS Custom Properties (Design Tokens)
   ============================================================= */
:root {
  /* Brand Colors */
  --hcp-primary: #80c52e;
  --hcp-primary-dark: #65b345;
  --hcp-primary-light: #e8f5e3;
  --hcp-primary-rgb: 128, 197, 46;
  --hcp-primary-dark-rgb: 101, 179, 69;

  /* Neutral Colors */
  --hcp-white: #ffffff;
  --hcp-bg: #f4f7f6;
  --hcp-bg-alt: #e9edec;
  --hcp-text: #374151;
  --hcp-text-title: #111827;
  --hcp-text-muted: #6b7280;
  --hcp-border: #d1d5db;
  --hcp-border-light: #e5e7eb;

  /* Semantic Colors */
  --hcp-danger: #dc2626;
  --hcp-warning: #f59e0b;
  --hcp-info: #3b82f6;
  --hcp-success: #80c52e;

  /* Gradients */
  --hcp-gradient: linear-gradient(135deg, #80c52e, #65b345);
  --hcp-gradient-header: linear-gradient(135deg, #65b345, #4a8a2e);

  /* Typography */
  --hcp-font-heading: 'Poppins', sans-serif;
  --hcp-font-body: 'Open Sans', sans-serif;
  --hcp-font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Sizing */
  --hcp-navbar-height: 4rem;
  --hcp-navbar-height-lg: 4.5rem;
  --hcp-container-max: 1280px;
  --hcp-container-padding: 1rem;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;

  /* Z-index Scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-navbar: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* =============================================================
   2. Base / Reset
   ============================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--hcp-font-body);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--hcp-text);
  background-color: var(--hcp-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =============================================================
   3. Typography
   ============================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--hcp-font-heading);
  color: var(--hcp-text-title);
  line-height: 1.3;
  margin-top: 0;
  margin-bottom: var(--space-3);
}

h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

p {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

a {
  color: var(--hcp-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

small, .text-small {
  font-size: 0.75rem;
}

.text-muted {
  color: var(--hcp-text-muted);
}

.text-mono {
  font-family: var(--hcp-font-mono);
}

/* =============================================================
   4. Container & Layout
   ============================================================= */
.hcp-container {
  width: 100%;
  max-width: var(--hcp-container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--hcp-container-padding);
  padding-right: var(--hcp-container-padding);
}

/* Simple Flex Grid */
.hcp-row {
  display: flex;
  flex-wrap: wrap;
  margin-left: calc(var(--space-3) * -1);
  margin-right: calc(var(--space-3) * -1);
}

.hcp-row > [class*="hcp-col"] {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
  width: 100%;
}

.hcp-col-12 { flex: 0 0 100%; max-width: 100%; }
.hcp-col-6 { flex: 0 0 50%; max-width: 50%; }
.hcp-col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.hcp-col-3 { flex: 0 0 25%; max-width: 25%; }

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

.hcp-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hcp-gap-1 { gap: var(--space-1); }
.hcp-gap-2 { gap: var(--space-2); }
.hcp-gap-3 { gap: var(--space-3); }
.hcp-gap-4 { gap: var(--space-4); }

/* Spacing Utilities */
.hcp-mt-4 { margin-top: var(--space-4); }
.hcp-mt-6 { margin-top: var(--space-6); }
.hcp-mt-8 { margin-top: var(--space-8); }
.hcp-mb-4 { margin-bottom: var(--space-4); }
.hcp-mb-6 { margin-bottom: var(--space-6); }
.hcp-p-4 { padding: var(--space-4); }
.hcp-p-6 { padding: var(--space-6); }

/* =============================================================
   5. Navbar
   ============================================================= */
.hcp-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--hcp-navbar-height);
  padding: 0 var(--hcp-container-padding);
  background-color: var(--hcp-white);
  border-bottom: 3px solid var(--hcp-primary);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
}

.hcp-navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--hcp-font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--hcp-text-title);
  text-decoration: none;
}

.hcp-navbar-brand img {
  height: 40px;
  width: auto;
}

.hcp-navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.hcp-nav-link {
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--hcp-text);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
}

.hcp-nav-link:hover,
.hcp-nav-link.active {
  color: var(--hcp-primary);
  background-color: var(--hcp-primary-light);
}

.hcp-navbar-toggler {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--hcp-text-title);
  font-size: 1.25rem;
}

/* =============================================================
   6. Buttons
   ============================================================= */
.hcp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1.25rem;
  font-family: var(--hcp-font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

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

.hcp-btn-primary {
  background-color: var(--hcp-primary);
  color: var(--hcp-white);
  border-color: var(--hcp-primary);
}

.hcp-btn-primary:hover {
  background-color: var(--hcp-primary-dark);
  border-color: var(--hcp-primary-dark);
  color: var(--hcp-white);
}

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

.hcp-btn-outline:hover {
  background-color: var(--hcp-primary);
  color: var(--hcp-white);
}

.hcp-btn-ghost {
  background-color: transparent;
  color: var(--hcp-text);
  border-color: transparent;
}

.hcp-btn-ghost:hover {
  background-color: var(--hcp-bg-alt);
  color: var(--hcp-text-title);
}

.hcp-btn-danger {
  background-color: var(--hcp-danger);
  color: var(--hcp-white);
  border-color: var(--hcp-danger);
}

.hcp-btn-danger:hover {
  background-color: #b91c1c;
  border-color: #b91c1c;
  color: var(--hcp-white);
}

.hcp-btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.hcp-btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.hcp-btn-block {
  display: flex;
  width: 100%;
}

.hcp-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* =============================================================
   7. Cards
   ============================================================= */
.hcp-card {
  background-color: var(--hcp-white);
  border: 1px solid var(--hcp-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.hcp-card:hover {
  box-shadow: var(--shadow-md);
}

.hcp-card-body {
  padding: var(--space-6);
}

.hcp-card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--hcp-border-light);
  background-color: var(--hcp-white);
  font-family: var(--hcp-font-heading);
  font-weight: 600;
  color: var(--hcp-text-title);
}

.hcp-card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--hcp-border-light);
  background-color: var(--hcp-bg);
}

.hcp-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

/* Card de Unidade / Sistema */
.hcp-unit-card {
  cursor: pointer;
  transition: all var(--transition-base);
}

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

.hcp-unit-card .hcp-card-image {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* =============================================================
   8. Tables
   ============================================================= */
.hcp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.hcp-table th {
  padding: 0.75rem 1rem;
  background-color: var(--hcp-primary);
  color: var(--hcp-white);
  font-family: var(--hcp-font-heading);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.hcp-table th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.hcp-table th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.hcp-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hcp-border-light);
  vertical-align: middle;
}

.hcp-table tbody tr {
  background-color: var(--hcp-white);
  transition: background-color var(--transition-fast);
}

.hcp-table tbody tr:nth-child(even) {
  background-color: var(--hcp-bg);
}

.hcp-table tbody tr:hover {
  background-color: var(--hcp-bg-alt);
}

.hcp-table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Card layout for tables on mobile */
@media (max-width: 767px) {
  .hcp-table-card-layout thead {
    display: none;
  }

  .hcp-table-card-layout tbody tr {
    display: block;
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    background-color: var(--hcp-white);
    border: 1px solid var(--hcp-border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .hcp-table-card-layout td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: none;
    background-color: transparent !important;
  }

  .hcp-table-card-layout td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--hcp-text-title);
    margin-right: var(--space-4);
  }
}

/* =============================================================
   9. Forms
   ============================================================= */
.hcp-form-group {
  margin-bottom: var(--space-4);
}

.hcp-form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--hcp-text-title);
}

.hcp-form-control {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--hcp-font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--hcp-text);
  background-color: var(--hcp-white);
  border: 1px solid var(--hcp-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  appearance: none;
}

.hcp-form-control:focus {
  outline: none;
  border-color: var(--hcp-primary);
  box-shadow: 0 0 0 3px rgba(var(--hcp-primary-rgb), 0.15);
}

.hcp-form-control::placeholder {
  color: var(--hcp-text-muted);
}

.hcp-form-control:disabled {
  background-color: var(--hcp-bg);
  cursor: not-allowed;
}

select.hcp-form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

textarea.hcp-form-control {
  min-height: 100px;
  resize: vertical;
}

/* Checkbox & Radio */
.hcp-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 0.875rem;
}

.hcp-check input[type="checkbox"],
.hcp-check input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--hcp-primary);
  cursor: pointer;
}

/* =============================================================
   10. Badges
   ============================================================= */
.hcp-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--hcp-primary-dark);
  background-color: var(--hcp-primary-light);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.hcp-badge-danger {
  color: #991b1b;
  background-color: #fef2f2;
}

.hcp-badge-warning {
  color: #92400e;
  background-color: #fffbeb;
}

.hcp-badge-info {
  color: #1e40af;
  background-color: #eff6ff;
}

/* =============================================================
   11. Alerts
   ============================================================= */
.hcp-alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid transparent;
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

.hcp-alert-success {
  background-color: #ecfdf5;
  border-color: var(--hcp-success);
  color: #065f46;
}

.hcp-alert-error {
  background-color: #fef2f2;
  border-color: var(--hcp-danger);
  color: #991b1b;
}

.hcp-alert-warning {
  background-color: #fffbeb;
  border-color: var(--hcp-warning);
  color: #92400e;
}

.hcp-alert-info {
  background-color: #eff6ff;
  border-color: var(--hcp-info);
  color: #1e40af;
}

/* =============================================================
   12. Footer
   ============================================================= */
.hcp-footer {
  background: var(--hcp-gradient);
  color: var(--hcp-white);
  padding: var(--space-8) 0;
  margin-top: auto;
}

.hcp-footer a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.hcp-footer a:hover {
  opacity: 1;
  color: var(--hcp-white);
}

.hcp-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hcp-footer-links li {
  margin-bottom: var(--space-2);
}

.hcp-footer-social {
  display: flex;
  gap: var(--space-3);
}

.hcp-footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.15);
  font-size: 1.125rem;
  transition: all var(--transition-fast);
}

.hcp-footer-social a:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

/* =============================================================
   13. Loading / Skeleton
   ============================================================= */
.hcp-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--hcp-border-light);
  border-top-color: var(--hcp-primary);
  border-radius: 50%;
  animation: hcp-spin 0.7s linear infinite;
}

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

.hcp-skeleton {
  background: linear-gradient(90deg, var(--hcp-bg) 25%, var(--hcp-bg-alt) 50%, var(--hcp-bg) 75%);
  background-size: 200% 100%;
  animation: hcp-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

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

/* =============================================================
   14. Section Titles (headings with divider lines)
   ============================================================= */
.hcp-section-title {
  text-align: center;
  margin-bottom: var(--space-8);
}

.hcp-section-title h2 {
  color: var(--hcp-primary);
  font-size: 1.25rem;
  margin-bottom: var(--space-3);
}

.hcp-section-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: 0 auto;
  max-width: 200px;
}

.hcp-section-divider::before,
.hcp-section-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background-color: var(--hcp-primary);
  border-radius: 1px;
}

/* =============================================================
   15. Dropdown
   ============================================================= */
.hcp-dropdown {
  position: relative;
  display: inline-block;
}

.hcp-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  margin-top: var(--space-2);
  padding: var(--space-2) 0;
  background-color: var(--hcp-white);
  border: 1px solid var(--hcp-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
}

.hcp-dropdown:hover .hcp-dropdown-menu,
.hcp-dropdown-menu.show {
  display: block;
}

.hcp-dropdown-item {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  color: var(--hcp-text);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.hcp-dropdown-item:hover {
  background-color: var(--hcp-primary-light);
  color: var(--hcp-primary-dark);
}

/* =============================================================
   16. Utilities
   ============================================================= */
.hcp-text-center { text-align: center; }
.hcp-text-left { text-align: left; }
.hcp-text-right { text-align: right; }
.hcp-text-green { color: var(--hcp-primary); }
.hcp-text-white { color: var(--hcp-white); }
.hcp-bg-white { background-color: var(--hcp-white); }
.hcp-bg-light { background-color: var(--hcp-bg); }
.hcp-bg-gradient { background: var(--hcp-gradient); }
.hcp-rounded { border-radius: var(--radius-md); }
.hcp-rounded-lg { border-radius: var(--radius-lg); }
.hcp-shadow { box-shadow: var(--shadow-md); }
.hcp-border { border: 1px solid var(--hcp-border-light); }
.hcp-w-full { width: 100%; }
.hcp-h-full { height: 100%; }
.hcp-d-none { display: none; }
.hcp-d-flex { display: flex; }
.hcp-d-block { display: block; }

/* =============================================================
   17. Responsive Breakpoints
   ============================================================= */

/* ≥ 576px (Tablet pequeno) */
@media (min-width: 576px) {
  body { font-size: 0.9375rem; }
  .hcp-container { padding-left: 1.5rem; padding-right: 1.5rem; }
  .hcp-col-sm-6 { flex: 0 0 50%; max-width: 50%; }
  .hcp-col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .hcp-col-sm-3 { flex: 0 0 25%; max-width: 25%; }
}

/* ≥ 768px (Tablet) */
@media (min-width: 768px) {
  body { font-size: 1rem; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.375rem; }
  .hcp-btn { padding: 0.75rem 1.5rem; }
  .hcp-navbar { height: var(--hcp-navbar-height-lg); }
  .hcp-navbar-brand img { height: 44px; }
  .hcp-col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .hcp-col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .hcp-col-md-3 { flex: 0 0 25%; max-width: 25%; }
}

/* ≥ 1024px (Desktop) */
@media (min-width: 1024px) {
  .hcp-container { padding-left: 2rem; padding-right: 2rem; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .hcp-col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .hcp-col-lg-3 { flex: 0 0 25%; max-width: 25%; }
  .hcp-d-lg-none { display: none; }
  .hcp-d-lg-block { display: block; }
  .hcp-d-lg-flex { display: flex; }
}

/* < 1024px (Mobile + Tablet — navbar collapse) */
@media (max-width: 1023px) {
  .hcp-navbar-toggler {
    display: block;
  }

  .hcp-navbar-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: var(--space-4);
    background-color: var(--hcp-white);
    border-bottom: 3px solid var(--hcp-primary);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
  }

  .hcp-navbar-nav.open {
    display: flex;
  }

  .hcp-nav-link {
    width: 100%;
    padding: var(--space-3) var(--space-4);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
