/* Native iOS/Mobile App Styling */

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: linear-gradient(180deg, #eaf2ff 0%, #f8fafc 36%, #ffffff 100%);
  overflow-x: hidden;
}

html.app-loading,
html.app-loading body {
  background: linear-gradient(180deg, #eaf2ff 0%, #dbeafe 46%, #f8fafc 100%);
}

html.app-loading body::before,
html.app-loading body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 220ms ease-out, transform 220ms ease-out;
  z-index: 99998;
}

html.app-loading body::before {
  background: rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(1.5px);
}

html.app-loading body::after {
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(88vw, 280px);
  border-radius: 16px;
  padding: 14px 16px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  font: 600 15px -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0.01em;
}

html.app-loading body::after {
  content: 'Indigo PDF\APreparing your tools...';
  white-space: pre;
  text-align: center;
}

html.dark.app-loading,
html.dark.app-loading body {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 48%, #334155 100%);
}

html.dark.app-loading body::before {
  background: rgba(2, 6, 23, 0.42);
  backdrop-filter: blur(2px);
}

html.dark.app-loading body::after {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.55);
}

html.app-loading body::before,
html.app-loading body::after {
  opacity: 1;
}

html.app-ready body::before,
html.app-ready body::after {
  opacity: 0;
  transform: translateY(-6px);
}

html.app-ready body::before,
html.app-ready body::after {
  visibility: hidden;
}

/* Safe area padding for notch/Dynamic Island */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

/* Main content container */
main {
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Native iOS-style cards */
.card, .bg-card {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  background: #ffffff;
  border: none;
}

.card:active, .bg-card:active {
  opacity: 0.95;
}

/* Native button styling */
button, .btn {
  font-family: inherit;
  -webkit-user-select: none;
  user-select: none;
  border-radius: 8px;
  transition: all 0.15s ease-out;
  active: opacity(0.8);
}

button:active, .btn:active {
  transform: scale(0.98);
  opacity: 0.8;
}

/* Remove blue selection highlight on iOS */
a, button, input {
  -webkit-tap-highlight-color: transparent;
}

/* Native input styling */
input, textarea, select {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.75rem;
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: #667eea;
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Remove iOS default styling */
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

input[type="date"]::-webkit-outer-spin-button,
input[type="date"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

/* Native scroll behavior */
* {
  -webkit-overflow-scrolling: touch;
}

/* Status bar safe area */
header, footer {
  padding-left: max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}

header {
  padding-top: max(0px, env(safe-area-inset-top));
}

footer {
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

/* Modal overlay for native feel */
.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
}

.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Native animation for page transitions */
@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

main {
  animation: slideInFromRight 0.25s ease-out;
}

/* Disable user selection on interactive elements */
button, a, [role="button"] {
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection only where needed */
p, .text-content, .description {
  -webkit-user-select: text;
  user-select: text;
}

/* Native-like loading state */
.loading-skeleton {
  background: linear-gradient(90deg, #e5e7eb 0%, #f3f4f6 50%, #e5e7eb 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Native alert styling */
.alert {
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.alert-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.alert-success {
  background-color: #dcfce7;
  color: #166534;
}

.alert-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.alert-info {
  background-color: #dbeafe;
  color: #1e40af;
}

/* Remove iOS gray overlay on long press */
* {
  -webkit-touch-callout: none;
}

/* Native form group styling */
.form-group {
  margin-bottom: 1.25rem;
}

/* Native separator lines */
hr {
  border: none;
  height: 1px;
  background-color: #e5e7eb;
  margin: 1rem 0;
}

/* Safe area for floating elements */
.floating-action-button {
  bottom: max(1rem, calc(1rem + env(safe-area-inset-bottom)));
  right: max(1rem, calc(1rem + env(safe-area-inset-right)));
}

/* Native badge styling */
.badge {
  border-radius: 999px;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Smooth transitions */
* {
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

/* Prevent flashing on page load */
html {
  background-color: #f8fafc;
}
