/**
 * Native App Feel - CSS
 * Makes the Capacitor app feel like a real native app
 */

/* ============================================
   DISABLE WEB BEHAVIORS
   ============================================ */

/* Remove tap highlight */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Prevent text selection on interactive elements */
button, a, .btn, .card, .list-item, [role="button"] {
  -webkit-user-select: none;
  user-select: none;
}

/* Disable pull-to-refresh globally (we control it manually) */
html, body {
  overscroll-behavior-y: contain;
}

/* ============================================
   INSTANT TAP FEEDBACK
   ============================================ */

/* Remove 300ms tap delay */
html {
  touch-action: manipulation;
}

/* All interactive elements get instant feedback */
button, a, .btn, .card-clickable, .list-item, 
input[type="submit"], input[type="button"],
[role="button"], .clickable {
  touch-action: manipulation;
  cursor: pointer;
}

/* ============================================
   NATIVE BUTTON PRESS STATES
   ============================================ */

/* Default pressed state - scale down */
button:active, .btn:active, [role="button"]:active,
input[type="submit"]:active, input[type="button"]:active {
  transform: scale(0.97);
  opacity: 0.9;
  transition: transform 0.05s ease, opacity 0.05s ease;
}

/* Restore on release */
button, .btn, [role="button"],
input[type="submit"], input[type="button"] {
  transform: scale(1);
  transition: transform 0.15s ease, opacity 0.15s ease, background-color 0.15s ease;
}

/* Primary buttons - darken on press */
.btn-primary:active, button.primary:active {
  background-color: var(--primary-700, #1d4ed8) !important;
}

/* Cards and list items - subtle press */
.card:active, .card-clickable:active, .list-item:active {
  transform: scale(0.98);
  opacity: 0.95;
}

/* Icon buttons - highlight on press */
.btn-icon:active, .icon-button:active, .back-btn:active {
  background-color: rgba(0, 0, 0, 0.1);
  transform: scale(0.9);
}

[data-theme="dark"] .btn-icon:active,
[data-theme="dark"] .icon-button:active,
[data-theme="dark"] .back-btn:active {
  background-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   MOMENTUM SCROLLING
   ============================================ */

/* Enable native-feeling scroll on iOS */
.scroll-container, .content, main, 
.dashboard-content, .page-content,
[data-scroll="true"] {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Hide scrollbars but keep functionality */
.hide-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

/* Fade in on page load */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply to main content */
.page-transition {
  animation: pageEnter 0.25s ease-out;
}

/* Slide from right (forward navigation) */
@keyframes slideFromRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in {
  animation: slideFromRight 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Slide from left (back navigation) */
@keyframes slideFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-back {
  animation: slideFromLeft 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Scale up (modal/card appearance) */
@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scale-in {
  animation: scaleUp 0.2s ease-out;
}

/* ============================================
   LOADING STATES
   ============================================ */

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-200, #e2e8f0) 25%,
    var(--neutral-100, #f1f5f9) 50%,
    var(--neutral-200, #e2e8f0) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-md, 8px);
}

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

[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-700, #334155) 25%,
    var(--neutral-600, #475569) 50%,
    var(--neutral-700, #334155) 75%
  );
  background-size: 200% 100%;
}

/* Button loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

.btn-primary.btn-loading::after {
  border-color: white;
  border-right-color: transparent;
}

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

/* ============================================
   FORM INPUT FOCUS
   ============================================ */

/* Native-feeling input focus */
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-500, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Prevent zoom on iOS */
input, select, textarea {
  font-size: 16px !important;
}

/* ============================================
   RIPPLE EFFECT (Android-style)
   ============================================ */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
  opacity: 0;
}

.ripple:active::before {
  width: 200%;
  height: 200%;
  opacity: 1;
  transition: 0s;
}

/* Dark ripple for light buttons */
.ripple-dark::before {
  background: rgba(0, 0, 0, 0.1);
}

/* ============================================
   BOTTOM SHEET STYLE MODALS
   ============================================ */

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface, white);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1000;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--neutral-300, #cbd5e1);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 999;
}

.bottom-sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  background: var(--neutral-800, #1e293b);
  color: white;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  background: var(--success-600, #059669);
}

.toast-error {
  background: var(--danger-600, #dc2626);
}

.toast-warning {
  background: var(--warning-600, #d97706);
}

/* ============================================
   NATIVE-STYLE LIST ITEMS
   ============================================ */

.native-list {
  background: var(--surface, white);
  border-radius: 12px;
  overflow: hidden;
}

.native-list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  min-height: 52px;
  border-bottom: 1px solid var(--divider, #f1f5f9);
  transition: background-color 0.1s ease;
}

.native-list-item:last-child {
  border-bottom: none;
}

.native-list-item:active {
  background-color: var(--neutral-100, #f1f5f9);
}

[data-theme="dark"] .native-list-item:active {
  background-color: var(--neutral-700, #334155);
}

.native-list-item-icon {
  width: 28px;
  height: 28px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.native-list-item-content {
  flex: 1;
}

.native-list-item-title {
  font-weight: 500;
  color: var(--text-primary);
}

.native-list-item-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.native-list-item-chevron {
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ============================================
   NATIVE-STYLE TOGGLE/SWITCH
   ============================================ */

.native-switch {
  position: relative;
  width: 51px;
  height: 31px;
  background: var(--neutral-300, #cbd5e1);
  border-radius: 31px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.native-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.native-switch.active {
  background: var(--primary-500, #3b82f6);
}

.native-switch.active::after {
  transform: translateX(20px);
}

