/**
 * PAT Mobile-First Design System
 * ==============================
 * CSS responsivo mobile-first para o Portal do Profissional (PAT)
 * 
 * Prioridades:
 * - Mobile first
 * - Touch-friendly (min 44px)
 * - Navegação simplificada
 * - Baixa carga cognitiva
 * - Performance percebida
 * 
 * Breakpoints:
 * - Mobile: < 640px
 * - Tablet: 640px - 1024px
 * - Desktop: > 1024px
 */

/* ==========================================================================
   1. VARIABLES MOBILE
   ========================================================================== */

:root {
  /* Touch Targets - Mínimo 44px para acessibilidade */
  --pat-touch-min: 44px;
  --pat-touch-comfortable: 48px;
  --pat-touch-large: 56px;
  
  /* Spacing Mobile */
  --pat-mobile-padding: 16px;
  --pat-mobile-gap: 12px;
  --pat-mobile-radius: 16px;
  
  /* Bottom Nav */
  --pat-bottom-nav-height: 64px;
  --pat-bottom-nav-safe: calc(var(--pat-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  
  /* Z-index layers */
  --pat-z-content: 1;
  --pat-z-header: 100;
  --pat-z-drawer: 200;
  --pat-z-modal: 300;
  --pat-z-bottom-nav: 400;
  --pat-z-toast: 500;
}

/* ==========================================================================
   2. BASE MOBILE RESET
   ========================================================================== */

/* Safe area support for notched devices */
.pat-body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Prevent horizontal scroll */
.pat-body,
.pat-layout,
.pat-content,
.pat-main {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Hide scrollbars on mobile (keep functionality) */
@media (max-width: 1024px) {
  .pat-body::-webkit-scrollbar,
  .pat-main::-webkit-scrollbar,
  .pat-content::-webkit-scrollbar {
    display: none;
  }
  
  .pat-body,
  .pat-main,
  .pat-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* ==========================================================================
   3. BOTTOM NAVIGATION (MOBILE)
   ========================================================================== */

.pat-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--pat-z-bottom-nav);
  background: var(--pat-surface);
  border-top: 1px solid var(--pat-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: none;
}

.pat-bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--pat-bottom-nav-height);
  max-width: 500px;
  margin: 0 auto;
}

.pat-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--pat-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px;
  transition: color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.pat-bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--pat-primary);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.pat-bottom-nav-item.is-active {
  color: var(--pat-primary);
}

.pat-bottom-nav-item.is-active::before {
  width: 24px;
}

.pat-bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.pat-bottom-nav-item:active .pat-bottom-nav-icon {
  transform: scale(0.9);
}

.pat-bottom-nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Badge para notificações */
.pat-bottom-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--pat-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Show bottom nav on mobile/tablet */
@media (max-width: 1024px) {
  .pat-bottom-nav {
    display: block;
  }
  
  /* Add padding to main content to account for bottom nav */
  .pat-body.has-bottom-nav .pat-main {
    padding-bottom: var(--pat-bottom-nav-safe);
  }
}

/* ==========================================================================
   4. MOBILE LAYOUT ADJUSTMENTS
   ========================================================================== */

@media (max-width: 1024px) {
  /* Hide desktop sidebar */
  .pat-sidebar {
    display: none !important;
  }
  
  /* Full width content */
  .pat-layout {
    display: block;
  }
  
  .pat-content {
    width: 100%;
    max-width: 100%;
  }
  
  /* Compact header */
  .pat-header {
    position: sticky;
    top: 0;
    z-index: var(--pat-z-header);
  }
  
  .pat-topbar {
    padding: 10px var(--pat-mobile-padding);
    gap: 10px;
  }
  
  /* Hide menu toggle when using bottom nav */
  .pat-body.has-bottom-nav .pat-menu-toggle {
    display: none !important;
  }
  
  /* Compact brand on mobile */
  .pat-brand-text span {
    display: none;
  }
  
  .pat-brand strong {
    font-size: 14px;
  }
  
  /* User area compact */
  .pat-user {
    gap: 8px;
  }
  
  .pat-user span {
    display: none;
  }
  
  /* Main content padding */
  .pat-main {
    padding: var(--pat-mobile-padding);
  }
  
  .pat-container {
    padding: 0;
  }
}

@media (max-width: 640px) {
  .pat-topbar {
    padding: 8px 12px;
  }
  
  .pat-main {
    padding: 12px;
  }
  
  /* Even more compact brand */
  .pat-brand-logo,
  .pat-brand-fallback {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }
}

/* ==========================================================================
   5. MOBILE PAGE HEADER
   ========================================================================== */

.pat-page-header {
  display: flex;
  flex-direction: column;
  gap: var(--pat-mobile-gap);
  margin-bottom: var(--pat-mobile-gap);
}

.pat-page-title h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
}

.pat-page-title p {
  font-size: 13px;
  color: var(--pat-muted);
  margin: 4px 0 0;
  display: none;
}

/* Actions horizontal scroll on mobile */
.pat-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pat-actions::-webkit-scrollbar {
  display: none;
}

@media (max-width: 640px) {
  .pat-page-title h1 {
    font-size: 18px;
  }
  
  .pat-actions {
    margin: 0 -12px;
    padding: 0 12px 4px;
  }
}

/* ==========================================================================
   6. MOBILE CARDS (AGENDA)
   ========================================================================== */

.pat-mobile-agenda {
  display: flex;
  flex-direction: column;
  gap: var(--pat-mobile-gap);
}

.pat-mobile-agenda-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  position: sticky;
  top: 0;
  background: var(--pat-bg);
  z-index: 10;
}

.pat-mobile-agenda-date {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pat-mobile-agenda-date h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.pat-mobile-agenda-date span {
  font-size: 12px;
  color: var(--pat-muted);
}

.pat-mobile-agenda-nav {
  display: flex;
  gap: 8px;
}

.pat-mobile-agenda-nav button {
  width: var(--pat-touch-min);
  height: var(--pat-touch-min);
  border-radius: 12px;
  border: 1px solid var(--pat-border);
  background: var(--pat-surface);
  color: var(--pat-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.pat-mobile-agenda-nav button:active {
  background: var(--pat-bg);
  transform: scale(0.95);
}

/* Appointment Card */
.pat-appointment-card {
  background: var(--pat-surface);
  border: 1px solid var(--pat-border);
  border-radius: var(--pat-mobile-radius);
  padding: 16px;
  display: flex;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: var(--pat-touch-large);
}

.pat-appointment-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pat-appointment-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding-right: 14px;
  border-right: 2px solid var(--pat-border);
}

.pat-appointment-time strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--pat-text);
  line-height: 1;
}

.pat-appointment-time span {
  font-size: 11px;
  color: var(--pat-muted);
  margin-top: 2px;
}

.pat-appointment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pat-appointment-client-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pat-appointment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--pat-muted-bg, #f1f5f9);
  color: var(--pat-text);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.pat-appointment-avatar.has-photo {
  background: #e5e7eb;
}

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

.pat-appointment-client {
  font-size: 15px;
  font-weight: 700;
  color: var(--pat-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pat-appointment-service {
  font-size: 13px;
  color: var(--pat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pat-appointment-professional {
  font-size: 12px;
  color: var(--pat-primary);
  font-weight: 500;
  margin-top: 2px;
}

.pat-appointment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pat-appointment-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Status colors */
.pat-appointment-status.status-agendado {
  background: var(--pat-status-agendado-bg);
  color: var(--pat-status-agendado-text);
}

.pat-appointment-status.status-confirmado {
  background: var(--pat-status-confirmado-bg);
  color: var(--pat-status-confirmado-text);
}

.pat-appointment-status.status-em_atendimento {
  background: var(--pat-status-em_atendimento-bg);
  color: var(--pat-status-em_atendimento-text);
}

.pat-appointment-status.status-concluido {
  background: var(--pat-status-concluido-bg);
  color: var(--pat-status-concluido-text);
}

.pat-appointment-status.status-aguardando_confirmacao {
  background: var(--pat-status-aguardando_confirmacao-bg);
  color: var(--pat-status-aguardando_confirmacao-text);
}

.pat-appointment-status.status-cancelado {
  background: var(--pat-status-cancelado-bg);
  color: var(--pat-status-cancelado-text);
}

.pat-appointment-status.status-nao_compareceu {
  background: var(--pat-status-nao_compareceu-bg);
  color: var(--pat-status-nao_compareceu-text);
}

.pat-appointment-status.status-cliente_em_espera {
  background: var(--pat-status-cliente_em_espera-bg);
  color: var(--pat-status-cliente_em_espera-text);
}

.pat-appointment-status.status-reagendado,
.pat-appointment-status.status-remarcado {
  background: var(--pat-status-reagendado-bg);
  color: var(--pat-status-reagendado-text);
}

.pat-appointment-status.status-bloqueio {
  background: var(--pat-status-bloqueio-bg);
  color: var(--pat-status-bloqueio-text);
}

/* Action button on card */
.pat-appointment-action {
  display: flex;
  align-items: center;
  padding-left: 12px;
}

.pat-appointment-action button {
  width: var(--pat-touch-min);
  height: var(--pat-touch-min);
  border-radius: 12px;
  border: none;
  background: var(--pat-primary);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.pat-appointment-action button:active {
  background: var(--pat-primary-pressed);
  transform: scale(0.95);
}

/* Empty state */
.pat-agenda-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  background: var(--pat-surface);
  border: 1px solid var(--pat-border);
  border-radius: var(--pat-mobile-radius);
}

.pat-agenda-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.pat-agenda-empty h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
}

.pat-agenda-empty p {
  font-size: 13px;
  color: var(--pat-muted);
  margin: 0;
}

/* ==========================================================================
   7. SWIPE DAY NAVIGATION
   ========================================================================== */

.pat-swipe-container {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.pat-swipe-track {
  display: flex;
  transition: transform 0.3s ease;
}

.pat-swipe-day {
  flex: 0 0 100%;
  min-width: 100%;
}

/* Day indicator dots */
.pat-day-indicators {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
}

.pat-day-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pat-border);
  transition: background 0.2s ease, transform 0.2s ease;
}

.pat-day-dot.is-active {
  background: var(--pat-primary);
  transform: scale(1.25);
}

.pat-day-dot.is-today {
  border: 2px solid var(--pat-primary);
}

/* ==========================================================================
   8. COMPACT CALENDAR PICKER
   ========================================================================== */

.pat-calendar-modal {
  position: fixed;
  inset: 0;
  z-index: var(--pat-z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pat-calendar-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.pat-calendar-modal.is-open .pat-calendar-sheet {
  transform: translateY(0);
}

.pat-calendar-sheet {
  background: var(--pat-surface);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.pat-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pat-calendar-header h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.pat-calendar-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--pat-border);
  background: var(--pat-surface);
  color: var(--pat-text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pat-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pat-calendar-nav span {
  font-size: 15px;
  font-weight: 700;
}

.pat-calendar-nav button {
  width: var(--pat-touch-min);
  height: var(--pat-touch-min);
  border-radius: 12px;
  border: 1px solid var(--pat-border);
  background: var(--pat-surface);
  color: var(--pat-text);
  font-size: 16px;
  cursor: pointer;
}

.pat-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.pat-calendar-day-name {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--pat-muted);
  padding: 8px 0;
  text-transform: uppercase;
}

.pat-calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--pat-text);
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pat-calendar-day:disabled {
  color: var(--pat-disabled-text);
  cursor: default;
}

.pat-calendar-day.is-today {
  border: 2px solid var(--pat-primary);
}

.pat-calendar-day.is-selected {
  background: var(--pat-primary);
  color: #fff;
}

.pat-calendar-day:not(:disabled):not(.is-selected):active {
  background: var(--pat-primary-light);
}

/* ==========================================================================
   9. ATTENDANCE TABS (ATENDIMENTO)
   ========================================================================== */

.pat-attendance-tabs {
  display: flex;
  gap: 0;
  background: var(--pat-surface);
  border: 1px solid var(--pat-border);
  border-radius: 14px;
  padding: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pat-attendance-tabs::-webkit-scrollbar {
  display: none;
}

.pat-attendance-tab {
  flex: 1;
  min-width: max-content;
  height: var(--pat-touch-min);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--pat-muted);
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.pat-attendance-tab.is-active {
  background: var(--pat-primary);
  color: #fff;
}

.pat-attendance-tab:not(.is-active):active {
  background: var(--pat-bg);
}

.pat-attendance-tab-icon {
  font-size: 16px;
}

/* Tab panels */
.pat-attendance-panels {
  position: relative;
}

.pat-attendance-panel {
  display: none;
  padding-top: 16px;
}

.pat-attendance-panel.is-active {
  display: block;
}

/* Swipeable panels */
.pat-attendance-swipe {
  overflow: hidden;
  touch-action: pan-y;
}

.pat-attendance-swipe-track {
  display: flex;
  transition: transform 0.3s ease;
}

.pat-attendance-swipe-panel {
  flex: 0 0 100%;
  min-width: 100%;
  padding: 16px 0;
}

/* ==========================================================================
   10. MOBILE FORMS
   ========================================================================== */

/* Drawer form container */
.pat-mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--pat-z-drawer);
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pat-mobile-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.pat-mobile-drawer.is-open .pat-mobile-drawer-content {
  transform: translateY(0);
}

.pat-mobile-drawer-content {
  background: var(--pat-surface);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.pat-mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--pat-border);
  flex-shrink: 0;
}

.pat-mobile-drawer-header h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.pat-mobile-drawer-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--pat-border);
  background: var(--pat-surface);
  color: var(--pat-text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pat-mobile-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.pat-mobile-drawer-footer {
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--pat-border);
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.pat-mobile-drawer-footer button {
  flex: 1;
  height: var(--pat-touch-comfortable);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pat-mobile-drawer-footer .btn-cancel {
  border: 1px solid var(--pat-border);
  background: var(--pat-surface);
  color: var(--pat-text);
}

.pat-mobile-drawer-footer .btn-submit {
  border: none;
  background: var(--pat-primary);
  color: #fff;
}

/* Mobile form fields */
.pat-form-field {
  margin-bottom: 16px;
}

.pat-form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--pat-text);
  margin-bottom: 8px;
}

.pat-form-input {
  width: 100%;
  height: var(--pat-touch-comfortable);
  padding: 0 16px;
  border: 1px solid var(--pat-border);
  border-radius: 12px;
  font-size: 16px; /* Prevent zoom on iOS */
  font-weight: 500;
  color: var(--pat-text);
  background: var(--pat-surface);
  -webkit-appearance: none;
  appearance: none;
}

.pat-form-input:focus {
  outline: none;
  border-color: var(--pat-primary);
  box-shadow: 0 0 0 3px var(--pat-primary-light);
}

.pat-form-input::placeholder {
  color: var(--pat-muted);
}

.pat-form-textarea {
  height: auto;
  min-height: 120px;
  padding: 12px 16px;
  resize: vertical;
}

.pat-form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* ==========================================================================
   11. TOUCH-FRIENDLY BUTTONS
   ========================================================================== */

/* Button base reset for touch */
.pat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--pat-touch-min);
  padding: 0 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, background 0.15s ease;
  border: none;
}

.pat-btn:active {
  transform: scale(0.97);
}

.pat-btn-primary {
  background: var(--pat-primary);
  color: #fff;
}

.pat-btn-primary:active {
  background: var(--pat-primary-pressed);
}

.pat-btn-secondary {
  background: var(--pat-secondary);
  color: #fff;
}

.pat-btn-secondary:active {
  background: var(--pat-secondary-pressed);
}

.pat-btn-outline {
  background: var(--pat-surface);
  color: var(--pat-text);
  border: 1px solid var(--pat-border);
}

.pat-btn-outline:active {
  background: var(--pat-bg);
}

.pat-btn-danger {
  background: var(--pat-danger);
  color: #fff;
}

.pat-btn-danger:active {
  background: var(--pat-danger-pressed);
}

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

.pat-btn-ghost:active {
  background: var(--pat-bg);
}

/* Large button (for primary actions) */
.pat-btn-lg {
  min-height: var(--pat-touch-large);
  padding: 0 24px;
  font-size: 16px;
}

/* Full width button */
.pat-btn-block {
  width: 100%;
}

/* Icon only button */
.pat-btn-icon {
  width: var(--pat-touch-min);
  height: var(--pat-touch-min);
  padding: 0;
}

.pat-btn-icon-lg {
  width: var(--pat-touch-large);
  height: var(--pat-touch-large);
}

/* ==========================================================================
   12. MOBILE CARDS (GENERAL)
   ========================================================================== */

@media (max-width: 1024px) {
  .pat-card {
    border-radius: var(--pat-mobile-radius);
    margin-bottom: var(--pat-mobile-gap);
  }
  
  .pat-card-header {
    padding: 14px 16px;
  }
  
  .pat-card-header h2 {
    font-size: 15px;
  }
  
  .pat-card-body {
    padding: 16px;
  }
  
  /* Metrics compact */
  .pat-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .pat-metric {
    padding: 12px;
  }
  
  .pat-metric strong {
    font-size: 20px;
  }
  
  .pat-metric span {
    font-size: 11px;
  }
}

@media (max-width: 640px) {
  .pat-card-header {
    padding: 12px 14px;
  }
  
  .pat-card-body {
    padding: 14px;
  }
  
  .pat-metrics {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   13. SKELETON LOADERS
   ========================================================================== */

.pat-skeleton {
  background: linear-gradient(90deg, var(--pat-border) 25%, var(--pat-bg-subtle) 50%, var(--pat-border) 75%);
  background-size: 200% 100%;
  animation: pat-skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes pat-skeleton-pulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.pat-skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.pat-skeleton-text:last-child {
  width: 60%;
}

.pat-skeleton-title {
  height: 20px;
  width: 70%;
  margin-bottom: 12px;
}

.pat-skeleton-card {
  background: var(--pat-surface);
  border: 1px solid var(--pat-border);
  border-radius: var(--pat-mobile-radius);
  padding: 16px;
  display: flex;
  gap: 14px;
  min-height: 80px;
}

.pat-skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.pat-skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================================================
   14. TOAST NOTIFICATIONS
   ========================================================================== */

.pat-toast-container {
  position: fixed;
  bottom: calc(var(--pat-bottom-nav-safe) + 16px);
  left: 16px;
  right: 16px;
  z-index: var(--pat-z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.pat-toast {
  background: var(--pat-text);
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  animation: pat-toast-in 0.3s ease;
}

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

.pat-toast.is-exiting {
  animation: pat-toast-out 0.2s ease forwards;
}

@keyframes pat-toast-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.pat-toast-icon {
  font-size: 18px;
}

.pat-toast-success {
  background: var(--pat-success-text);
}

.pat-toast-error {
  background: var(--pat-danger);
}

.pat-toast-warning {
  background: var(--pat-warning-text);
}

/* ==========================================================================
   15. PULL TO REFRESH
   ========================================================================== */

.pat-pull-refresh {
  position: relative;
  overflow: hidden;
}

.pat-pull-refresh-indicator {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pat-surface);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: top 0.2s ease;
}

.pat-pull-refresh.is-pulling .pat-pull-refresh-indicator {
  top: 16px;
}

.pat-pull-refresh-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--pat-border);
  border-top-color: var(--pat-primary);
  border-radius: 50%;
  animation: pat-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   16. FLOATING ACTION BUTTON (FAB)
   ========================================================================== */

.pat-fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--pat-bottom-nav-safe) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: var(--pat-primary);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
  z-index: 50;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.pat-fab:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

/* FAB with label */
.pat-fab-extended {
  width: auto;
  padding: 0 20px;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

/* ==========================================================================
   17. QUICK ACTIONS BAR
   ========================================================================== */

.pat-quick-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--pat-surface);
  border: 1px solid var(--pat-border);
  border-radius: var(--pat-mobile-radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pat-quick-actions::-webkit-scrollbar {
  display: none;
}

.pat-quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--pat-text);
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}

.pat-quick-action:active {
  background: var(--pat-bg);
}

.pat-quick-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--pat-primary-light);
  color: var(--pat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.pat-quick-action-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

/* ==========================================================================
   18. VISUAL BOARD MOBILE OVERRIDES
   ========================================================================== */

@media (max-width: 1024px) {
  /* Hide complex visual board on mobile, show cards instead */
  .pat-visual-board {
    display: none;
  }
  
  .pat-mobile-agenda {
    display: flex;
  }
  
  /* Visual day compact */
  .pat-vday {
    min-height: auto;
  }
  
  .pat-vday-head {
    grid-template-columns: 50px 1fr;
    gap: 8px;
  }
  
  .pat-vday-body {
    grid-template-columns: 50px 1fr;
    gap: 8px;
  }
  
  .pat-vday-hour {
    font-size: 11px;
    padding: 4px;
  }
  
  .pat-vevent {
    left: 4px;
    right: 4px;
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* ==========================================================================
   19. DETAIL MODAL MOBILE
   ========================================================================== */

@media (max-width: 1024px) {
  .pat-card#patDetail {
    position: fixed;
    inset: 0;
    margin: 0;
    border-radius: 0;
    z-index: var(--pat-z-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .pat-card#patDetail .pat-card-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--pat-border);
  }
  
  .pat-card#patDetail .pat-card-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
   20. ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus visible for keyboard navigation */
.pat-btn:focus-visible,
.pat-form-input:focus-visible,
.pat-bottom-nav-item:focus-visible,
.pat-appointment-card:focus-visible {
  outline: 2px solid var(--pat-primary);
  outline-offset: 2px;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  .pat-appointment-card {
    border-width: 2px;
  }
  
  .pat-btn {
    border: 2px solid currentColor;
  }
}

/* ==========================================================================
   21. TABLET SPECIFIC (HORIZONTAL)
   ========================================================================== */

@media (min-width: 641px) and (max-width: 1024px) {
  /* Two column layout for tablets */
  .pat-mobile-agenda {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .pat-mobile-agenda-header {
    grid-column: 1 / -1;
  }
  
  /* Larger touch targets */
  .pat-bottom-nav-inner {
    max-width: 600px;
  }
  
  /* More metrics visible */
  .pat-metrics {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Wider drawers */
  .pat-mobile-drawer-content {
    max-width: 500px;
    margin: 0 auto;
    border-radius: 24px;
    margin-bottom: 24px;
    max-height: calc(100vh - 48px);
  }
}

/* Tablet landscape */
@media (min-width: 900px) and (max-width: 1024px) and (orientation: landscape) {
  .pat-mobile-agenda {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .pat-metrics {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ==========================================================================
   22. HIDE/SHOW UTILITIES
   ========================================================================== */

.pat-show-mobile {
  display: none !important;
}

.pat-hide-mobile {
  display: block;
}

@media (max-width: 1024px) {
  .pat-show-mobile {
    display: block !important;
  }
  
  .pat-hide-mobile {
    display: none !important;
  }
  
  .pat-show-mobile-flex {
    display: flex !important;
  }
  
  .pat-show-mobile-grid {
    display: grid !important;
  }
}

@media (max-width: 640px) {
  .pat-show-phone {
    display: block !important;
  }
  
  .pat-hide-phone {
    display: none !important;
  }
}

/* ==========================================================================
   23. PROFESSIONAL PAGER MOBILE STYLES
   ========================================================================== */

@media (max-width: 640px) {
  /* Improved pager controls for mobile */
  .pat-prof-pager-controls {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--pat-surface);
    padding: 12px 16px;
    border-bottom: 1px solid var(--pat-border);
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
  }
  
  .pat-prof-pager-controls button {
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--pat-primary);
    color: white;
    border: none;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
  
  .pat-prof-pager-controls button:disabled {
    opacity: 0.3;
    background: var(--pat-muted);
  }
  
  .pat-prof-pager-indicator {
    font-size: 14px;
    font-weight: 700;
    color: var(--pat-text);
    text-align: center;
    flex: 1;
  }
  
  /* Mobile visual agenda: 1 professional per page, full width */
  .pat-vday {
    --time-col: 60px;
    --prof-col-width: calc(100vw - 76px); /* Full width minus time column and padding */
  }
  
  /* Allow horizontal scroll for full columns */
  .pat-prof-viewport {
    overflow-x: auto;
    overflow-y: hidden;
  }
  
  .pat-prof-page {
    overflow: visible;
  }
  
  .pat-vday-timehead {
    padding: 8px 6px;
    font-size: 10px;
    position: sticky;
    left: 0;
    background: rgba(17, 24, 39, 0.03);
    z-index: 3;
  }
  
  .pat-vday-profhead {
    padding: 10px 8px;
    font-size: 12px;
    font-weight: 700;
    min-width: var(--prof-col-width);
  }
  
  .pat-vday-time {
    height: 48px;
    padding: 6px 6px;
    font-size: 11px;
  }
  
  .pat-vday-timecol {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--pat-surface);
  }
  
  /* Larger touch targets for events */
  .pat-vevent {
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 10px;
  }
  
  .pat-vevent-name {
    font-size: 13px;
    font-weight: 600;
  }
  
  .pat-vevent-time,
  .pat-vevent-service {
    font-size: 11px;
  }
  
  .pat-vday-col {
    min-width: var(--prof-col-width);
  }
}

/* Tablet professional pager */
@media (min-width: 641px) and (max-width: 1024px) {
  .pat-vday {
    --time-col: 70px;
    --prof-col-width: 160px;
  }
  
  .pat-prof-pager-controls button {
    min-width: 44px;
    min-height: 44px;
  }
  
  .pat-prof-viewport {
    overflow-x: auto;
    overflow-y: hidden;
  }
}
