/* ============================================================
   OuiAmi Native UI — iOS-Native Experience Layer
   Version 1.0 — March 24, 2026

   Provides iOS-native bottom tab bar, page transitions,
   and native-feeling interactions across all pages.
   ============================================================ */

/* ── Tab bar animations ── */
@keyframes tabBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.2); }
  50% { transform: scale(0.95); }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes activeDot {
  from { transform: translateX(-50%) scale(0); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ── iOS BOTTOM TAB BAR ── */
.oa-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(255,255,255,0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0,0,0,0.12);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  padding-top: 6px;
  height: auto;
  min-height: 50px;
}

.oa-tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #8E8E93;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
  position: relative;
}

.oa-tab-bar a .tab-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.oa-tab-bar a.active {
  color: #52B788;
}

.oa-tab-bar a.active .tab-icon {
  animation: tabBounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Green dot under active tab */
.oa-tab-bar a.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #52B788;
  animation: activeDot 0.3s ease both;
  box-shadow: 0 0 6px rgba(82,183,136,0.4);
}

/* Tap feedback */
.oa-tab-bar a:active .tab-icon {
  transform: scale(0.85);
}

/* Tab bar SVG icon styling */
.oa-tab-bar a svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: none;
  transition: filter 0.2s ease;
}

.oa-tab-bar a.active svg {
  filter: drop-shadow(0 1px 3px rgba(82,183,136,0.35));
}

/* ── BODY PADDING FOR TAB BAR ── */
body.has-tab-bar {
  padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ── iOS PAGE TRANSITIONS ── */
@keyframes oa-slide-in {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes oa-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes oa-scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Staggered card entrance */
.oa-stagger > * {
  opacity: 0;
  animation: oa-slide-up 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.oa-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.oa-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.oa-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.oa-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.oa-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.oa-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.oa-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.oa-stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* ── iOS NATIVE INTERACTIONS ── */

/* Tap feedback — scale down on press like native iOS */
.oa-pressable {
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, opacity 0.1s ease;
  cursor: pointer;
}
.oa-pressable:active {
  transform: scale(0.97);
  opacity: 0.85;
}

/* Card press effect */
.oa-card-press {
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.15s ease;
}
.oa-card-press:active {
  transform: scale(0.98);
}

/* ── iOS TOGGLE SWITCH ── */
.oa-toggle {
  position: relative;
  width: 51px;
  height: 31px;
  appearance: none;
  -webkit-appearance: none;
  background: #E9E9EA;
  border-radius: 31px;
  border: none;
  outline: none;
  cursor: pointer;
  transition: background 0.25s ease;
  flex-shrink: 0;
}
.oa-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 1px 1px rgba(0,0,0,0.06);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.oa-toggle:checked {
  background: #52B788;
}
.oa-toggle:checked::after {
  transform: translateX(20px);
}

/* ── iOS-STYLE ACTION SHEET / BOTTOM SHEET ── */
.oa-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.25s ease;
  display: none;
}
.oa-sheet-overlay.open {
  display: block;
  opacity: 1;
}

.oa-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.oa-sheet.open {
  transform: translateY(0);
}

.oa-sheet-handle {
  width: 36px;
  height: 5px;
  background: #E0E0E0;
  border-radius: 3px;
  margin: 0 auto 16px;
}

/* ── iOS-STYLE SEGMENTED CONTROL ── */
.oa-segmented {
  display: flex;
  background: rgba(118,118,128,0.12);
  border-radius: 9px;
  padding: 2px;
  position: relative;
}

.oa-segmented button {
  flex: 1;
  padding: 7px 12px;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  z-index: 1;
}

.oa-segmented button.active {
  color: #000;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 1px rgba(0,0,0,0.04);
}

/* ── iOS-STYLE PULL TO REFRESH INDICATOR ── */
.oa-ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.3s ease;
}
.oa-ptr-indicator.visible {
  transform: translateX(-50%) translateY(60px);
}
.oa-ptr-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid #E0E0E0;
  border-top-color: #52B788;
  border-radius: 50%;
  animation: oa-spin 0.8s linear infinite;
}
@keyframes oa-spin {
  to { transform: rotate(360deg); }
}

/* ── iOS-STYLE SEARCH BAR ── */
.oa-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(118,118,128,0.12);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 16px;
}
.oa-search-bar svg {
  width: 16px;
  height: 16px;
  color: #8E8E93;
  flex-shrink: 0;
}
.oa-search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 15px;
  color: #000;
  outline: none;
}
.oa-search-bar input::placeholder {
  color: #8E8E93;
}

/* ── iOS-STYLE LIST / TABLE ROWS ── */
.oa-list {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 0.5px solid rgba(0,0,0,0.08);
}

.oa-list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 0.5px solid rgba(0,0,0,0.06);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
  cursor: pointer;
}
.oa-list-item:last-child {
  border-bottom: none;
}
.oa-list-item:active {
  background: rgba(0,0,0,0.04);
}
.oa-list-item .chevron {
  color: #C7C7CC;
  font-size: 14px;
  margin-left: auto;
}

/* ── NATIVE OVERSCROLL BEHAVIOR ── */
html {
  overscroll-behavior: none;
}

/* ── SELECTION & FOCUS ── */
::selection {
  background: rgba(82,183,136,0.25);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #52B788 !important;
  box-shadow: 0 0 0 3px rgba(82,183,136,0.12);
}

/* ── iOS-STYLE BADGE ── */
.oa-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #FF3B30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: -apple-system, sans-serif;
}

.oa-badge-green {
  background: #52B788;
}

/* ── Ami FAB pulse animation ── */
@keyframes amiBreathe {
  0%, 100% { box-shadow: 0 4px 14px rgba(82,183,136,0.25); }
  50% { box-shadow: 0 6px 24px rgba(82,183,136,0.45); }
}

/* ── FLOATING AMI BUTTON ── */
.oa-ami-fab {
  position: fixed;
  right: 16px;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  width: 52px;
  height: 52px;
  animation: amiBreathe 3s ease-in-out infinite;
  border-radius: 50%;
  background: linear-gradient(135deg, #52B788, #2D6A4F);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(82,183,136,0.35), 0 2px 6px rgba(0,0,0,0.1);
  z-index: 9998;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.oa-ami-fab:active {
  transform: scale(0.9);
  box-shadow: 0 2px 8px rgba(82,183,136,0.3);
}
.oa-ami-fab svg {
  width: 24px;
  height: 24px;
}

/* ── RESPONSIVE TAB BAR ── */
@media (min-width: 769px) {
  /* On larger screens (iPad), tab bar can be wider with labels */
  .oa-tab-bar {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
    border-left: 0.5px solid rgba(0,0,0,0.08);
    border-right: 0.5px solid rgba(0,0,0,0.08);
  }
}

/* ── DARK MODE SUPPORT ── */
@media (prefers-color-scheme: dark) {
  .oa-tab-bar {
    background: rgba(28,28,30,0.92);
    border-top-color: rgba(255,255,255,0.08);
  }
  .oa-tab-bar a {
    color: #8E8E93;
  }
  .oa-tab-bar a.active {
    color: #52B788;
  }
  .oa-toggle {
    background: #39393D;
  }
  .oa-segmented {
    background: rgba(118,118,128,0.24);
  }
  .oa-segmented button.active {
    background: #2C2C2E;
    color: #fff;
  }
}
