@import url('./brand-tokens.css');

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  line-height: 1.5;
  overflow-x: clip;
}

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
.btn,
.submit-btn,
.cta-primary,
.cta-secondary,
a.btn,
.nav-toggle,
input[type="submit"],
.btn-cancel-inline,
.admin-badge-x,
.ms-dropdown-clear {
  min-height: 44px;
  min-width: 44px;
}

select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea {
  min-height: 44px;
  font-size: 1rem;
}

.section,
.card,
.hospital-box,
.box,
.sidebar,
.login-panel,
.hero-panel {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .section + .section,
  .card + .card,
  .card-panel + .card-panel,
  .main > * + *,
  .cal-main > * + *,
  .inicio-main > * + *,
  .admin-page .page-shell > * + *,
  .admin-page .section + .section,
  .admin-tabs + .admin-filter-bar,
  .admin-filter-bar + .admin-tab-panel,
  .admin-section-nav + .admin-section,
  .page-shell > .section + .section,
  .login-page > .login-panel {
    margin-top: 1.25rem;
  }

  .admin-page .page-shell > :first-child,
  .cal-main > :first-child {
    margin-top: 0;
  }

  .main,
  .cal-main,
  .admin-page .page-shell {
    padding-top: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: none;
  padding: 0.5rem max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 1rem;
  isolation: isolate;
}

.site-nav .nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #00b2a9;
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
}

.site-nav .nav-brand img,
.site-nav .nav-brand img.nav-brand-logo {
  height: 32px;
  width: auto;
  max-width: min(120px, 42vw);
  max-height: 32px;
  object-fit: contain;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  color: #4b4f54;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav-links a {
  padding: 0.5rem 0.85rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: #4b4f54;
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: background 0.15s;
}

.nav-links a:hover {
  color: var(--qs-teal-dark, #008f88);
}

.nav-links a.active {
  background: transparent;
  color: var(--qs-navy, #1a2e35);
  font-weight: 700;
  box-shadow: none;
}

.nav-links a.nav-logout {
  color: #e03e52;
}

.nav-menu-primary {
  display: contents;
}

.nav-menu-utils {
  display: contents;
}

.nav-user {
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.nav-notif-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  min-height: 44px;
}

.nav-notif-btn:hover { background: #e6f7f6; }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #e03e52;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notif-badge.is-hidden { display: none; }

.notif-panel {
  position: fixed;
  top: 56px;
  right: 1rem;
  width: min(380px, calc(100vw - 2rem));
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  z-index: 200;
  padding: 1rem;
}

.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.notif-panel-header h2 {
  font-size: 1rem;
  margin: 0;
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notif-item {
  padding: 0.85rem;
  border-bottom: 1px solid #f0f1f2;
  font-size: 0.875rem;
  border-radius: 8px;
}

.notif-item.unread {
  background: #f0fdfc;
}

.notif-item strong {
  display: block;
  margin-bottom: 0.25rem;
}

.notif-item time {
  display: block;
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

.notif-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.notif-actions button {
  font-size: 0.875rem;
  padding: 0 0.65rem;
  min-height: 44px;
}

.room-thumb,
.cal-room-icon {
  max-width: 100%;
  object-fit: contain;
}

.notif-delete-btn {
  color: #e03e52;
}

.notif-empty {
  padding: 1.25rem 0.5rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  .notif-panel {
    right: max(0.5rem, env(safe-area-inset-right));
    left: max(0.5rem, env(safe-area-inset-left));
    width: auto;
    top: calc(56px + env(safe-area-inset-top));
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.35rem max(0.75rem, env(safe-area-inset-right)) 0.75rem max(0.75rem, env(safe-area-inset-left));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
    z-index: 150;
    max-height: min(78vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-menu-primary {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-bottom: 0.5rem;
  }

  .nav-menu-primary a {
    width: 100%;
    justify-content: flex-start;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    font-size: 0.9375rem;
  }

  .nav-menu-utils {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.65rem;
    border-top: 1px solid #eef0f2;
  }

  .nav-menu-utils .nav-notif-btn {
    width: auto;
    min-width: 44px;
    flex-shrink: 0;
    padding: 0.5rem 0.65rem;
  }

  .nav-menu-utils .nav-user {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0;
    font-size: 0.875rem;
    color: #4b4f54;
  }

  .nav-menu-utils .nav-logout {
    width: auto;
    margin-left: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  body.nav-menu-open {
    overflow: hidden;
  }
}

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

.notif-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1200;
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.9rem 1rem;
  border-radius: 0.95rem;
  background: #1a2e35;
  color: #fff;
  box-shadow: 0 16px 40px rgba(26, 46, 53, 0.24);
  font-size: 0.9375rem;
}

.notif-toast strong {
  display: block;
  margin-bottom: 0.2rem;
}

@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;
  }

  .loading-spinner {
    animation: none !important;
  }

  .brand-loader-overlay {
    backdrop-filter: none !important;
  }
}
