/* iOS Pure CSS Design System */
:root {
  color-scheme: light dark;
  
  /* Light Mode Variables */
  --ios-bg: #F2F2F7;
  --ios-card: #FFFFFF;
  --ios-text: #000000;
  --ios-text-secondary: #8E8E93;
  --ios-text-tertiary: #C7C7CC;
  --ios-border: rgba(60, 60, 67, 0.18);
  --ios-primary: #007AFF;
  --ios-primary-active: #0060C8;
  --ios-danger: #FF3B30;
  --ios-success: #34C759;
  --ios-glass: rgba(255, 255, 255, 0.85);
  
  /* Additional Accents */
  --ios-purple: #AF52DE;
  --ios-orange: #FF9500;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark Mode Variables */
    --ios-bg: #000000;
    --ios-card: #1C1C1E;
    --ios-text: #FFFFFF;
    --ios-text-secondary: #EBEBF5;
    --ios-text-tertiary: rgba(235, 235, 245, 0.3);
    --ios-border: rgba(84, 84, 88, 0.65);
    --ios-primary: #0A84FF;
    --ios-primary-active: #086ED4;
    --ios-danger: #FF453A;
    --ios-success: #32D74B;
    --ios-glass: rgba(28, 28, 30, 0.85);
    
    --ios-purple: #BF5AF2;
    --ios-orange: #FF9F0A;
  }
}

/* Base Restyle */
html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  background-color: var(--ios-bg);
  color: var(--ios-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Typography */
h1, h2, h3, h4, p {
  margin: 0;
}

/* Animations */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Semantic Layout Components */
.ios-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background-color: var(--ios-bg);
}

.ios-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 0.5px solid var(--ios-border);
  background-color: var(--ios-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}

.ios-header-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.ios-header-left, .ios-header-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
}
.ios-header-left { left: 16px; }
.ios-header-right { right: 16px; }

.ios-header-btn {
  background: none;
  border: none;
  color: var(--ios-primary);
  font-size: 17px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ios-header-btn:active {
  opacity: 0.5;
}

.ios-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Lists and Groups */
.ios-list {
  background-color: var(--ios-card);
  border-radius: 10px;
  overflow: hidden;
}

.ios-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--ios-card);
  border-bottom: 0.5px solid var(--ios-border);
  transition: background-color 0.2s;
  cursor: pointer;
}
.ios-list-item:last-child {
  border-bottom: none;
}
.ios-list-item:active {
  background-color: var(--ios-border);
}

/* Cards */
.ios-card {
  background-color: var(--ios-card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.ios-card-glass {
  background-color: var(--ios-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 0.5px solid var(--ios-border);
  border-radius: 18px;
  padding: 16px;
}

/* Typography elements */
.ios-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.ios-subtitle {
  font-size: 15px;
  color: var(--ios-text-secondary);
  line-height: 1.3;
}

.ios-caption {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--ios-text-secondary);
  font-weight: 500;
  margin-left: 16px;
  margin-bottom: 6px;
  letter-spacing: -0.1px;
}

/* Buttons */
.ios-btn {
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 16px;
  width: 100%;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ios-btn:active {
  transform: scale(0.97);
  opacity: 0.8;
}

.ios-btn-primary {
  background-color: var(--ios-primary);
  color: #FFFFFF;
}

.ios-btn-secondary {
  background-color: var(--ios-border);
  color: var(--ios-primary);
}

.ios-btn-danger {
  background-color: rgba(255, 69, 58, 0.1);
  color: var(--ios-danger);
}

/* Quick Actions Grid */
.ios-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.ios-action-card {
  background-color: var(--ios-card);
  border-radius: 14px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
}
.ios-action-card:active {
  background-color: var(--ios-border);
}
.ios-action-icon {
  font-size: 28px;
  color: var(--ios-primary);
}
.ios-action-text {
  font-size: 14px;
  font-weight: 500;
}

/* Tab Bar */
.ios-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(50px + env(safe-area-inset-bottom));
  background-color: var(--ios-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--ios-border);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 4px;
  z-index: 100;
}

.ios-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ios-text-secondary);
  background: none;
  border: none;
  cursor: pointer;
}
.ios-tab-item.active {
  color: var(--ios-primary);
}
.ios-tab-icon {
  font-size: 24px;
}
.ios-tab-text {
  font-size: 10px;
  font-weight: 500;
}

/* Modals / Action Sheets */
.ios-sheet-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s;
}

.ios-sheet {
  width: 100%;
  background-color: var(--ios-card);
  border-radius: 12px 12px 0 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.ios-sheet-handle {
  width: 36px;
  height: 5px;
  background-color: var(--ios-text-tertiary);
  border-radius: 3px;
  margin: 0 auto 16px auto;
}

/* Utilities */
.hidden { display: none !important; }
.material-icons-round { font-family: 'Material Icons Round'; }


/* Adaptive overrides for Tailwind utility classes in Light Mode */
@media (prefers-color-scheme: light) {
  .text-white { color: var(--ios-text) !important; }
  .text-white\\/90 { color: rgba(0,0,0,0.9) !important; }
  .text-white\\/80 { color: rgba(0,0,0,0.8) !important; }
  .text-white\\/70 { color: rgba(0,0,0,0.7) !important; }
  
  .text-gray-400 { color: var(--ios-text-secondary) !important; }
  .text-gray-500 { color: var(--ios-text-tertiary) !important; }
  .text-gray-300 { color: #666666 !important; }
  
  .border-white\\/10, .border-white\\/5 { border-color: var(--ios-border) !important; }
  
  .bg-white\\/5 { background-color: rgba(0,0,0,0.05) !important; }
  .bg-white\\/10 { background-color: rgba(0,0,0,0.08) !important; }
  .bg-white { background-color: var(--ios-card) !important; }

  /* Ensure main UI keeps the right background */
  body, .ios-screen { background-color: var(--ios-bg) !important; }
}
