/* VetConnect — final responsive safety layer
   Loaded after page-specific CSS so layout adapts without changing the design system. */
html { scrollbar-gutter: stable; overflow-x: clip; }
body { min-width: 0; overflow-x: clip; }
*, *::before, *::after { min-width: 0; }
img, svg, video, canvas { max-width: 100%; }
button, input, select, textarea { max-width: 100%; }
.container, .admin-main, .admin-content { width: 100%; min-width: 0; }

/* Large displays: keep content readable instead of stretching edge-to-edge. */
@media (min-width: 1440px) {
  :root { --content-max: 1240px; --gutter: 32px; }
  .landing-hero-grid, .about-container, .loc-container, .svc-container,
  .booking-container, .client-body { max-width: 1240px; margin-inline: auto; }
}
@media (min-width: 1920px) {
  :root { --content-max: 1320px; --gutter: 40px; }
  .landing-hero-grid, .about-container, .loc-container, .svc-container,
  .booking-container, .client-body { max-width: 1320px; }
}

/* Tablet / compact laptop */
@media (max-width: 1100px) {
  :root { --gutter: 20px; }
  .landing-hero-grid { gap: clamp(24px, 4vw, 48px); }
  .hero-copy h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
  .hero-pets { max-width: min(48vw, 520px); margin-inline: auto; }
  .footer-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; }
  .footer-col-action { grid-column: 1 / -1; }

  .admin-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .admin-main { padding-inline: clamp(16px, 3vw, 28px); }
  .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 720px; }
  .calendar-grid { min-width: 680px; }
}

/* Surface / tablet widths */
@media (max-width: 900px) {
  :root { --gutter: 18px; }
  .site-header .nav-row { min-height: 68px; }
  .brand-name-full small { display: none; }

  .landing-hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(280px, .95fr); align-items: center; }
  .hero-pets { width: 100%; max-width: 440px; }
  .hero-actions { flex-wrap: wrap; }

  .about-story-grid, .about-value-grid { grid-template-columns: 1fr; }
  .about-clinic-visual { max-width: 760px; margin-inline: auto; }
  .service-select-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .booking-layout { grid-template-columns: 1fr; }
  .booking-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar, .staff-sidebar { position: sticky; top: 0; width: 100%; max-height: none; overflow: visible; z-index: 50; }
  .admin-main { min-width: 0; padding: 22px var(--gutter) 40px; }
  .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-nav { display: flex; flex-wrap: wrap; gap: 6px; }
  .admin-nav a { flex: 1 1 150px; }
}

/* Phones */
@media (max-width: 700px) {
  :root { --gutter: 16px; }
  .container { padding-inline: var(--gutter); }
  h1 { font-size: clamp(1.9rem, 9vw, 2.5rem); }
  h2 { font-size: clamp(1.45rem, 7vw, 1.9rem); }
  p.lede { font-size: 1rem; }

  .landing-hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero-copy p, .hero-copy .lede { margin-inline: auto; }
  .hero-actions { justify-content: center; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .hero-pets { max-width: 380px; margin: 4px auto 0; }

  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .service-select-grid { grid-template-columns: 1fr; }
  .service-select-card { min-width: 0; }
  .booking-summary-grid { grid-template-columns: 1fr; }
  .booking-actions { flex-direction: column; align-items: stretch; }
  .booking-actions .btn { width: 100%; justify-content: center; }

  .footer-columns { grid-template-columns: 1fr; gap: 22px; }
  .footer-col-action { grid-column: auto; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 6px; }

  .admin-main { padding-inline: var(--gutter); }
  .admin-stat-grid { grid-template-columns: 1fr; }
  .admin-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-nav a { min-width: 0; width: 100%; }
  .admin-topbar { flex-wrap: wrap; gap: 10px; }
  .admin-topbar > * { max-width: 100%; }
  .calendar-toolbar, .calendar-head { flex-wrap: wrap; gap: 10px; }
  .calendar-view-switcher { width: 100%; }
  .calendar-view-btn { flex: 1 1 0; }
  .calendar-grid { min-width: 620px; }

  .admin-table-wrap { margin-inline: -2px; }
  .admin-table { min-width: 680px; }
  .admin-table th, .admin-table td { white-space: nowrap; }

  .staff-dashboard-page .admin-shell { grid-template-columns: 1fr; }
  .staff-dashboard-page .staff-sidebar { width: 100%; }
  .staff-dashboard-page .admin-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .staff-dashboard-page .mini-appt-row { flex-wrap: wrap; gap: 8px; }
  .staff-dashboard-page .staff-panel-heading { flex-direction: column; align-items: stretch; }
  .staff-dashboard-page .staff-panel-heading .btn { width: 100%; justify-content: center; }
}

@media (max-width: 420px) {
  :root { --gutter: 13px; }
  .site-header .nav-row { min-height: 62px; }
  .brand { gap: 7px; font-size: 1rem; }
  .brand img { width: 34px; height: 34px; }
  .nav-actions .btn, .nav-links .btn { padding-inline: 13px; }
  .admin-nav { grid-template-columns: 1fr; }
  .dashboard-actions { grid-template-columns: 1fr !important; }
  .dash-card, .staff-dashboard-page .staff-schedule-panel { padding: 16px; }
}

/* Landscape phones / short viewports: reduce vertical crowding. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 600px) {
  .landing-hero { padding-block: 26px; }
  .landing-hero-grid { min-height: auto; }
  .hero-pets { max-height: 58vh; object-fit: contain; }
  .site-header .nav-row { min-height: 60px; }
}

/* Avoid accidental flex/grid overflow from long labels. */
.hero-copy, .dash-card, .admin-panel, .booking-card, .about-story-copy,
.footer-col, .admin-topbar, .staff-panel-heading { overflow-wrap: anywhere; }

/* =========================================================
   Smooth manual-resize layer
   Keeps layouts stable between Chrome device presets and
   prevents awkward "in-between" widths while dragging.
   ========================================================= */

/* Compact desktop / laptop: reduce density before the tablet jump. */
@media (min-width: 1021px) and (max-width: 1199px) {
  .container { padding-inline: clamp(18px, 2.4vw, 28px); }
  .landing .nav-row, .modern-nav .nav-row { padding-inline: clamp(18px, 2.8vw, 30px); }
  .landing .nav-links, .modern-nav .nav-links { gap: clamp(12px, 2vw, 24px); }
  .landing .nav-links a, .modern-nav .nav-links a { font-size: .88rem; padding-inline: 1px; }
  .landing .site-header .brand { font-size: .98rem; gap: 8px; }
  .landing .site-header .brand img { width: 40px; height: 40px; }
  .landing .nav-actions { gap: 7px; }
  .landing .nav-actions .btn { padding-inline: 12px; }

  .landing .landing-hero-grid {
    grid-template-columns: minmax(0, 1fr) minmax(300px, .82fr);
    padding-left: clamp(20px, 3vw, 34px);
    gap: clamp(20px, 3vw, 40px);
  }
  .landing .hero-copy h1 { font-size: clamp(2.15rem, 4vw, 3.1rem); }
  .landing .hero-copy .lede { font-size: clamp(.96rem, 1.25vw, 1.05rem); }
}

/* At this width the full desktop navigation becomes crowded before the
   existing 860px mobile breakpoint. Switch it earlier and keep the same
   menu behavior, so dragging through this range stays usable. */
@media (max-width: 1020px) {
  .site-header .nav-row { min-height: 68px; }
  .site-header .brand-name-full small { display: none; }

  .site-header .nav-toggle { display: block; }
  .site-header .nav-links {
    position: fixed;
    top: 68px;
    right: 0;
    left: 0;
    background: var(--color-white);
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }
  .site-header .nav-links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .site-header .nav-links a {
    color: var(--color-ink);
    padding: 12px var(--gutter);
    border-radius: 0;
  }
  .site-header .nav-links a:hover { background: var(--color-blue-pale); color: var(--color-blue-deep); }
  .site-header .nav-links a.is-active { background: var(--color-lime); color: var(--color-white); border-radius: 0; }

  .site-header .nav-actions {
    position: fixed;
    top: calc(68px + 178px);
    left: 0;
    right: 0;
    background: var(--color-white);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px var(--gutter) 18px;
    border-bottom: 1px solid var(--color-border);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }
  .site-header .nav-actions.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .site-header .nav-actions .btn { justify-content: center; width: 100%; }
  .site-header .btn-outline { border-color: var(--color-blue); color: var(--color-blue-deep); }
  .site-header .btn-primary { background: var(--color-blue); color: var(--color-white); }

  .landing .landing-hero-grid {
    padding-left: clamp(18px, 3vw, 30px);
    gap: clamp(18px, 3vw, 36px);
  }
}

/* Tablet/large-phone transition: make the hero fluid instead of letting
   the image and text compete for a fixed amount of space. */
@media (min-width: 701px) and (max-width: 900px) {
  .landing .landing-hero-grid {
    grid-template-columns: minmax(0, 1fr) minmax(240px, .78fr);
    padding-left: clamp(18px, 3vw, 28px);
    padding-right: clamp(18px, 3vw, 28px);
    gap: clamp(16px, 3vw, 30px);
  }
  .landing .hero-copy h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
  .landing .hero-copy .lede { font-size: clamp(.94rem, 1.8vw, 1.02rem); }
  .landing .hero-actions { gap: 10px; }
  .landing .hero-actions .btn { flex: 1 1 180px; }

  .admin-main, .staff-area .admin-main, .admin-area .admin-main {
    padding-inline: clamp(16px, 2.5vw, 24px);
  }
}

/* Very narrow landscape/tablet widths: prevent fixed-width controls from
   creating a horizontal page jump during manual resizing. */
@media (min-width: 701px) and (max-width: 820px) {
  .landing .hero-actions .btn { min-width: 0; }
  .dashboard-actions, .admin-dashboard-header, .panel-heading,
  .staff-panel-heading { gap: 10px; }
  .admin-stat-grid-modern { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Make the transition into phone layout happen slightly earlier for
   intermediate widths where two-column content becomes cramped. */
@media (max-width: 760px) {
  .landing .landing-hero-grid { grid-template-columns: 1fr; text-align: center; }
  .landing .hero-copy p, .landing .hero-copy .lede { margin-inline: auto; }
  .landing .hero-actions { justify-content: center; }

  .about-value-grid, .loc-feature-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .about-value-grid, .loc-feature-grid { grid-template-columns: 1fr; }
  .landing .nav-actions { top: calc(62px + 178px); }
  .landing .nav-links { top: 62px; }
}

/* =========================================================
   Mobile unified navbar correction
   Keeps every menu item visible while manually resizing.
   The original landing/hero artwork is not modified here.
   ========================================================= */
@media (max-width: 1020px) {
  .unified-header .nav-links {
    z-index: 1001;
    top: 68px;
    max-height: none;
    overflow: visible;
  }

  .unified-header .nav-links a {
    flex: 0 0 auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
  }

  /* Four links occupy a predictable panel; keep the action panel below it. */
  .unified-header .nav-actions {
    z-index: 1000;
    top: 278px;
    box-sizing: border-box;
  }

  .unified-header .account-menu,
  .unified-header .account-menu-inner,
  .unified-header .guest-login-link {
    width: 100%;
    min-width: 0;
  }

  .unified-header .guest-login-link,
  .unified-header .account-toggle.logged-in {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    max-width: none;
    box-sizing: border-box;
    padding: 7px 14px;
    color: var(--color-blue-deep) !important;
    background: var(--color-blue-pale) !important;
    border: 1px solid var(--color-blue) !important;
    border-radius: 12px;
    text-decoration: none !important;
    white-space: nowrap;
  }

  .unified-header .guest-login-link .account-avatar,
  .unified-header .account-toggle.logged-in .account-avatar {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    color: var(--color-blue);
    background: #fff;
  }

  .unified-header .guest-login-link > span:last-child,
  .unified-header .account-toggle.logged-in .account-name {
    display: block;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .unified-header .nav-links {
    top: 62px;
  }

  .unified-header .nav-actions {
    top: 272px;
  }
}

/* =========================================================
   Admin + staff sidebar on phones/tablets: compact top bar.
   Row 1 = logo + Logout, row 2 = scrollable nav pills.
   (Final override: earlier admin/staff rules conflicted and clipped Logout.)
   ========================================================= */
@media (max-width: 900px) {
  .admin-area .admin-shell .admin-sidebar,
  .staff-area .admin-shell .admin-sidebar {
    position: sticky !important; top: 0; z-index: 60;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "top foot" "nav nav";
    align-items: center; gap: 8px 10px;
    height: auto !important; min-height: 0 !important;
    padding: 10px 14px 8px !important;
    overflow: visible !important;
    border-right: 0 !important;
  }
  .admin-area .admin-sidebar-top,
  .staff-area .staff-sidebar-top { grid-area: top; display: flex !important; min-height: 0 !important; margin: 0 !important; min-width: 0; }
  .admin-area .admin-sidebar .brand,
  .staff-area .admin-sidebar .brand { display: flex !important; align-items: center; gap: 10px; padding: 0 !important; min-width: 0; }
  .admin-area .admin-sidebar .brand img,
  .staff-area .admin-sidebar .brand img { width: 36px !important; height: 36px !important; flex: 0 0 36px; }
  .admin-area .admin-sidebar .brand-name-full,
  .staff-area .admin-sidebar .brand-name-full { display: block !important; font-size: .95rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-area .sidebar-collapse,
  .staff-area .sidebar-collapse { display: none !important; }

  .admin-area .admin-sidebar-foot,
  .staff-area .admin-sidebar-foot { grid-area: foot; margin: 0 !important; padding: 0 !important; border: 0 !important; }
  .admin-area .admin-sidebar-foot a,
  .staff-area .admin-sidebar-foot a { padding: 8px 10px !important; white-space: nowrap; }
  .admin-area .admin-sidebar-foot a span,
  .staff-area .admin-sidebar-foot a span { display: inline !important; }

  .admin-area .admin-nav,
  .staff-area .admin-nav {
    grid-area: nav; display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; align-items: center;
    gap: 6px !important; margin: 0 !important; padding: 0 0 4px !important;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .admin-area .admin-nav::-webkit-scrollbar,
  .staff-area .admin-nav::-webkit-scrollbar { display: none; }
  .admin-area .admin-nav-label,
  .staff-area .admin-nav-label { display: none !important; }
  .admin-area .admin-nav a,
  .staff-area .admin-nav a { flex: 0 0 auto !important; width: auto !important; white-space: nowrap; padding: 8px 12px !important; justify-content: flex-start !important; }
  .admin-area .admin-shell.sidebar-collapsed .admin-nav a span,
  .staff-area .admin-shell.sidebar-collapsed .admin-nav a span { display: inline !important; }
}


/* Final responsive safeguards for admin/staff dashboards and sidebars */
.admin-area .admin-shell, .staff-area .admin-shell { min-width: 0; }
.admin-area .admin-main, .staff-area .admin-main { min-width: 0; max-width: 100%; }
.admin-area .admin-sidebar .brand-name-full small,
.staff-area .admin-sidebar .brand-name-full small { overflow-wrap: anywhere; }
.admin-area .admin-nav a, .staff-area .admin-nav a { min-width: 0; }
.admin-area .admin-panel, .staff-area .admin-panel,
.admin-area .admin-stat-grid, .staff-area .admin-stat-grid { min-width: 0; }
.admin-activity-page .admin-main { min-width: 0; }
.admin-activity-page .admin-panel { min-width: 0; }
.admin-activity-page .activity-filter-row > * { flex: 1 1 180px; min-width: 0; }
.admin-activity-page .activity-history-copy { min-width: 0; overflow-wrap: anywhere; }
.admin-activity-page .activity-history-empty { padding: 14px 0; color: #647f91; }
.admin-activity-page .activity-history-empty strong { display: block; color: #183b4e; margin-bottom: 4px; }
.admin-activity-page .activity-history-empty p { margin: 0; }
@media (max-width: 900px) {
  .admin-area .admin-sidebar .brand-name-full, .staff-area .admin-sidebar .brand-name-full { white-space: normal; overflow-wrap: anywhere; }
  .admin-area .admin-nav, .staff-area .admin-nav { max-width: 100%; }
  .admin-area .admin-shell, .staff-area .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-area .admin-main, .staff-area .admin-main { padding-left: clamp(12px, 3vw, 24px); padding-right: clamp(12px, 3vw, 24px); }
}
@media (max-width: 480px) {
  .admin-area .admin-sidebar, .staff-area .admin-sidebar { padding: 8px 10px !important; }
  .admin-area .admin-sidebar .brand-name-full, .staff-area .admin-sidebar .brand-name-full { font-size: .86rem; }
  .admin-area .admin-sidebar .brand-name-full small, .staff-area .admin-sidebar .brand-name-full small { font-size: .6rem; }
  .admin-area .admin-nav a, .staff-area .admin-nav a { padding: 7px 9px !important; font-size: .8rem; }
}


/* VetConnect subtle motion enhancements: page entrance and interactive feedback */
@keyframes vetconnect-page-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Animate main page content on navigation without shifting the header/footer. */
body main {
  animation: vetconnect-page-enter 220ms ease-out both;
}
/* Small, consistent hover feedback for interactive elements. */
.site-header a, .site-footer a,
.btn, button, .service-select-card, .dash-card, .admin-panel {
  transition: color 160ms ease, background-color 160ms ease,
              border-color 160ms ease, box-shadow 160ms ease,
              transform 160ms ease;
}
.site-header .nav-links a:hover,
.site-footer a:hover { text-decoration-thickness: 2px; }
.btn:hover, button:hover { transform: translateY(-1px); }
.btn:active, button:active { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  body main { animation: none !important; }
  .site-header a, .site-footer a, .btn, button,
  .service-select-card, .dash-card, .admin-panel {
    transition: none !important;
  }
  .btn:hover, button:hover, .btn:active, button:active { transform: none !important; }
}
