/*
======================================
RASHAK AMS PWA - MOBILE-FIRST CSS
======================================
Organized for easy maintenance and customization
*/

/* =====================================
   1. FONTS & CSS VARIABLES
===================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root,
[data-theme="light"] {
  /* Colors */
  --primary-color: #71c16d;
  --primary-dark: #559c51;
  --primary-light: #66ff59;
  --secondary-color: #6c757d;
  --success-color: #198754;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #0dcaf0;

  /* Text Colors */
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-light: #8b949e;

  /* Backgrounds */
  --background: #d9d4d4;
  --surface: #ffffff;
  --border: #e9ecef;
  --border-light: #d5d5d5;

  /* Effects */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  --radius: 12px;
  --radius-sm: 8px;

  /* Layout */
  --spacing: 16px;
  --header-height: 56px;
  --content-width-mobile: 100%;
  --content-width-desktop: 800px;
  --content-width-large: 1000px;

  /* Safe Areas */
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --top-safe: env(safe-area-inset-top, 0px);

  /* Animations */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary-color: #4a8948;
  --primary-dark: #2b6028;
  --text-primary: #ffffff;
  --text-secondary: #a8a8a8;
  --text-light: #666666;
  --background: #000000;
  --surface: #1c1c1e;
  --border: #38383a;
  --border-light: #2c2c2e;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* =====================================
   2. BASE STYLES
===================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-size: 16px;
}

/* =====================================
   3. MAIN LAYOUT STRUCTURE
===================================== */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Navigation */
.top-nav {
  position: sticky;
  top: 0;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  padding-top: var(--top-safe);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing);
  height: var(--header-height);
  max-width: var(--content-width-desktop);
  margin: 0 auto;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 10px;
}

.nav-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  flex: 1;
  text-align: start;
  margin: 0 var(--spacing);
  color: var(--text-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  justify-content: flex-end;
}

/* Home button styling */
.home-btn {
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.home-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.home-btn:active {
  transform: scale(0.95);
}

.home-btn i {
  font-size: 16px;
}

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px var(--spacing);
  background: var(--success-color);
  color: white;
  font-size: 12px;
  font-weight: 500;
  gap: 6px;
  transition: var(--transition);
}

.connection-status.offline {
  background: var(--warning-color);
  color: var(--text-primary);
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Main Content Container */
.main-content {
  flex: 1;
  padding-bottom: var(--bottom-safe);
  min-height: calc(100vh - var(--header-height) - var(--top-safe));
  max-width: var(--content-width-desktop);
  margin: 0 auto;
  width: 100%;
}

/* =====================================
   4. SCREEN MANAGEMENT
===================================== */
.screen {
  display: none;
  min-height: calc(100vh - var(--header-height) - var(--top-safe));
  padding: var(--spacing);
  animation: fadeIn 0.3s ease-out;
}

.screen.active {
  display: block;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: calc(var(--spacing) * 1.5);
  padding-bottom: var(--spacing);
  border-bottom: 1px solid var(--border-light);
}

.screen-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

/* =====================================
   5. BUTTONS & INTERACTIVE ELEMENTS
===================================== */
.nav-btn,
.header-btn,
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  position: relative;
}

.header-btn {
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary-color);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  touch-action: manipulation;
  font-family: inherit;
}

.btn-primary:hover,
.nav-btn:hover,
.header-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-primary:active,
.nav-btn:active,
.header-btn:active {
  transform: scale(0.98);
}

/* Sync Badge */
.sync-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger-color);
  color: white;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  min-width: 16px;
  height: 16px;
  display: none;
  align-items: center;
  justify-content: center;
}

.sync-badge.show {
  display: flex;
}

/* =====================================
   6. HOME SCREEN COMPONENTS
===================================== */
/* Enhanced App Logo - Similar to PWA Popup */
.app-logo {
    margin-bottom: var(--spacing);
    display: flex;
    justify-content: center;
}

.app-logo-container {
    width: 120px;
    height: 70px;
    background: #ffffff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.app-logo-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 10px;
}

.app-logo-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(113, 193, 109, 0.3);
}

.app-logo img {
    width: 100px;
    height: 80px;
    border-radius: 10px;
    z-index: 1;
    position: relative;
}

/* Welcome section adjustments */
.welcome-section {
    text-align: center;
    padding: calc(var(--spacing) * 2) 0;
}

.welcome-section h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--text-primary);
    line-height: 1.2;
}

.welcome-section p {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.5;
    max-width: 320px;
    margin: 0 auto;
}

/* Dark theme support */
[data-theme="dark"] .app-logo-container {
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .app-logo-container:hover {
    box-shadow: 0 8px 25px rgba(113, 193, 109, 0.2);
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .app-logo-container {
        width: 120px;
        height: 50px;
        border-radius: 10px;
    }
    
    .app-logo img {
        width: 80px;
        height: 65px;
        border-radius: 12px;
    }
    
    .welcome-section h2 {
        font-size: 24px;
    }
    
    .welcome-section p {
        font-size: 15px;
        max-width: 280px;
    }
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing);
  margin: var(--spacing) 0 calc(var(--spacing) * 2);
}

.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--spacing);
  box-shadow: var(--shadow);
  text-align: center;
  transition: var(--transition);
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.card-count {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.card-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* =====================================
   7. GRID SYSTEMS
===================================== */

/* Stages Grid */
.stages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing);
}

.stage-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: calc(var(--spacing) * 1.5);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.stage-card:active {
  transform: scale(0.98);
}

.stage-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stage-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.stage-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0 auto var(--spacing);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  transition: var(--transition);
}

.stage-icon.farmer {
  background: linear-gradient(135deg, #28a745, #20c997);
}

.stage-icon.farmland {
  background: linear-gradient(135deg, #007bff, #6610f2);
}

.stage-icon.monitoring {
  background: linear-gradient(135deg, #ffc107, #fd7e14);
}

.stage-icon.recovery {
  background: linear-gradient(135deg, #17a2b8, #6f42c1);
}

.stage-icon.forms {
  background: linear-gradient(135deg, #6610f2, #e83e8c);
}

.stage-card:hover .stage-icon {
  transform: scale(1.1);
}

.stage-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.stage-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing);
}

.stage-count {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  background: var(--border-light);
  border-radius: 20px;
  color: var(--text-secondary);
  display: inline-block;
}

/* Forms Grid System */
.forms-container {
  padding: 0;
}

.forms-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing);
  margin-top: var(--spacing);
}

.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: calc(var(--spacing) * 2);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  min-height: 200px;
}

.form-card:active {
  transform: scale(0.98);
}

.form-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.form-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #17a2b8, #6f42c1);
}

.form-card-header {
  margin-bottom: calc(var(--spacing) * 1.5);
}

.form-card .form-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  background: linear-gradient(135deg, #17a2b8, #6f42c1);
  transition: var(--transition);
}

.form-card:hover .form-icon {
  transform: scale(1.1);
}

.form-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  line-height: 1.3;
}

.form-card p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: calc(var(--spacing) * 1.5);
  line-height: 1.5;
}

.form-meta {
  font-size: 13px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
}

/* =====================================
   8. FORM COMPONENTS
===================================== */
.mobile-form {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: calc(var(--spacing) * 2);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.form-section {
  padding: calc(var(--spacing) * 1.5);
  position: relative;
}

.form-section:not(:last-child) {
  border-bottom: 1px solid var(--border-light);
}

.form-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--spacing);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-field {
  margin-bottom: calc(var(--spacing) * 1.5);
}

.form-field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.required {
  color: var(--danger-color);
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 12px var(--spacing);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--surface);
  color: var(--text-primary);
  transition: var(--transition);
  font-family: inherit;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(65, 255, 59, 0.1);
}

.select-field {
  width: 100%;
  padding: 12px var(--spacing);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  touch-action: manipulation;
  position: relative;
}

.select-field:active {
  background: var(--border-light);
  transform: scale(0.99);
}

.select-field:hover {
  border-color: var(--primary-light);
}

.select-value {
  font-size: 16px;
  color: var(--text-primary);
  flex: 1;
  text-align: left;
}

.select-value[data-placeholder] {
  color: var(--text-light);
}

.select-field i {
  color: var(--text-secondary);
  font-size: 14px;
  transition: var(--transition);
}

.form-actions {
  padding: calc(var(--spacing) * 1.5);
  background: var(--border-light);
  border-top: 1px solid var(--border);
  margin-top: calc(var(--spacing) * 2);
}

/* Add to mobile-app.css */
.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 8px;
}

.checkbox-option,
.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
}

.checkbox-option input,
.radio-option input {
  margin: 0;
  width: 16px;
  height: 16px;
}

.checkbox-option label,
.radio-option label {
  margin: 0;
  font-weight: normal;
  cursor: pointer;
  flex: 1;
}

.form-description {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 16px;
}

.form-description p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* =====================================
   9. MODALS & OVERLAYS
===================================== */
.bottom-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: none;
}

.bottom-sheet.show {
  display: block;
}

.bottom-sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.bottom-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.bottom-sheet.show .bottom-sheet-content {
  transform: translateY(0);
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.show {
  display: flex;
}

/* =====================================
   10. TOAST NOTIFICATIONS
===================================== */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-safe) + var(--spacing));
  left: var(--spacing);
  right: var(--spacing);
  z-index: 2500;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing);
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: all;
  transform: translateY(-20px);
  opacity: 0;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  border-left: 4px solid var(--border);
}

.toast.success {
  border-left-color: var(--success-color);
}

.toast.error {
  border-left-color: var(--danger-color);
}

.toast.warning {
  border-left-color: var(--warning-color);
}

.toast.info {
  border-left-color: var(--info-color);
}

/* =====================================
   11. RESPONSIVE DESIGN (Mobile First)
===================================== */

/* Small Mobile Phones */
@media (max-width: 374px) {
  :root {
    --spacing: 12px;
  }

  .summary-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stages-grid,
  .forms-grid {
    grid-template-columns: 1fr;
  }

  .stage-card,
  .form-card {
    padding: var(--spacing);
    min-height: 150px;
  }
}

/* Large Mobile Phones */
@media (min-width: 375px) and (max-width: 767px) {
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-cards .summary-card:nth-child(3) {
    grid-column: 1 / -1;
  }

  .stages-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .forms-grid {
    grid-template-columns: 1fr;
    /* Keep 1 column for forms on mobile */
  }
}

/* Tablets */
@media (min-width: 768px) {
  .summary-cards {
    grid-template-columns: repeat(3, 1fr);
    max-width: 600px;
    margin: var(--spacing) auto calc(var(--spacing) * 2);
  }

  .stages-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 700px;
    margin: 0 auto;
  }

  .forms-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: calc(var(--spacing) * 1.5);
  }

  .forms-container {
    max-width: var(--content-width-desktop);
    margin: 0 auto;
    padding: 0 var(--spacing);
  }

  .mobile-form {
    max-width: 700px;
  }

  .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .main-content {
    max-width: var(--content-width-desktop);
    padding: 0 var(--spacing) var(--bottom-safe);
  }

  .stages-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 800px;
    margin: 0 auto;
  }

  .forms-grid {
    grid-template-columns: repeat(3, 1fr);
    /* 2 columns max for forms */
    gap: calc(var(--spacing) * 2);
  }

  .forms-container {
    max-width: var(--content-width-desktop);
    margin: 0 auto;
    padding: 0 var(--spacing);
  }

  .screen {
    padding: calc(var(--spacing) * 2) var(--spacing);
  }

  .bottom-sheet-content {
    left: 50%;
    right: auto;
    width: 500px;
    transform: translate(-50%, 100%);
    max-height: 70vh;
  }

  .bottom-sheet.show .bottom-sheet-content {
    transform: translate(-50%, 0);
  }

  .toast-container {
    left: auto;
    right: var(--spacing);
    width: 400px;
    bottom: var(--spacing);
  }
}

/* Large Desktop */
@media (min-width: 1440px) {
  .main-content {
    max-width: var(--content-width-large);
  }

  .forms-container {
    max-width: var(--content-width-large);
  }

  .stages-grid {
    max-width: 1000px;
  }

  .forms-grid {
    gap: calc(var(--spacing) * 2.5);
  }

  .mobile-form {
    max-width: 700px;
  }
}

/* =====================================
   12. THEME SUPPORT
===================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --text-primary: #ffffff;
    --text-secondary: #a8a8a8;
    --text-light: #666666;
    --background: #000000;
    --surface: #1c1c1e;
    --border: #38383a;
    --border-light: #2c2c2e;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  }

  .loading-overlay {
    background: rgba(0, 0, 0, 0.95);
  }
}

/* =====================================
   13. ANIMATIONS
===================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    transform: translateY(100px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* =====================================
   14. UTILITY CLASSES
===================================== */
.text-success {
  color: var(--success-color) !important;
}

.text-warning {
  color: var(--warning-color) !important;
}

.text-danger {
  color: var(--danger-color) !important;
}

.text-info {
  color: var(--info-color) !important;
}

.text-primary {
  color: var(--text-primary) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

.text-light {
  color: var(--text-light) !important;
}

.d-none {
  display: none !important;
}

.d-block {
  display: block !important;
}

.d-flex {
  display: flex !important;
}

.text-center {
  text-align: center !important;
}

.text-left {
  text-align: left !important;
}

.text-right {
  text-align: right !important;
}

.fw-bold {
  font-weight: 700 !important;
}

.fw-semibold {
  font-weight: 600 !important;
}

.fw-normal {
  font-weight: 400 !important;
}

/* =====================================
   15. ACCESSIBILITY & TOUCH OPTIMIZATION
===================================== */
@media (pointer: coarse) {

  .nav-btn,
  .header-btn,
  .btn-icon {
    min-height: 44px;
    min-width: 44px;
  }

  .form-field input,
  .form-field textarea,
  .select-field {
    min-height: 44px;
    font-size: 16px;
    /* Prevents zoom on iOS */
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================
   16. PHOTO UPLOAD COMPONENTS
===================================== */
.photo-section {
  text-align: center;
  padding: calc(var(--spacing) * 2);
}

.photo-upload {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.photo-upload:active {
  transform: scale(0.95);
}

.photo-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  opacity: 0;
  transition: var(--transition);
}

.photo-upload:hover .photo-overlay {
  opacity: 1;
}

.photo-overlay i {
  font-size: 20px;
  margin-bottom: 4px;
}

/* =====================================
   17. INPUT COMPONENTS
===================================== */
.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  transition: var(--transition);
}

.input-group:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(65, 255, 59, 0.1);
}

.input-group input {
  flex: 1;
  border: none;
  padding: 12px var(--spacing);
  font-size: 16px;
  background: transparent;
}

.input-group input:focus {
  outline: none;
  box-shadow: none;
}

.btn-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-color);
  color: var(--text-primary);
}

.btn-icon:hover {
  background: var(--primary-dark);
}

.btn-icon:active {
  transform: scale(0.95);
}

.help-text {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Special form field handling */
#farmlandScreen .form-field {
  display: block !important;
  margin-bottom: 16px;
}

#farmlandScreen .form-field[style*="display: none"] {
  display: block !important;
}

.form-field input[type="number"] {
  -webkit-appearance: textfield;
  -moz-appearance: textfield;
  appearance: textfield;
}

.form-field input[type="number"]::-webkit-outer-spin-button,
.form-field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-field input[type="date"] {
  color-scheme: light;
}

/* =====================================
   18. CHECKBOX & FILE UPLOAD
===================================== */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
}

.checkbox:checked {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: bold;
}

.checkbox-label {
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  flex: 1;
  margin-bottom: 0;
}

.file-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--spacing) * 2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--border-light);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.file-upload:hover {
  border-color: var(--primary-color);
  background: rgba(65, 255, 59, 0.1);
}

.file-upload:active {
  transform: scale(0.98);
}

.file-upload i {
  font-size: 24px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.file-upload span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.file-upload small {
  font-size: 12px;
  color: var(--text-secondary);
}

/* =====================================
   19. IMAGE PREVIEW COMPONENTS
===================================== */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: var(--spacing);
}

.image-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border-light);
  display: inline-block;
  margin: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 2;
}

.image-preview .remove-btn:hover {
  transform: scale(1.1);
  background: rgb(220, 53, 69);
}

.image-preview .image-number {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

/* Alternative image preview grid layout */
.image-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* =====================================
   20. BOTTOM SHEET DETAILED COMPONENTS
===================================== */
.bottom-sheet-header {
  position: relative;
  padding: var(--spacing);
  border-bottom: 1px solid var(--border-light);
  text-align: center;
  flex-shrink: 0;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.bottom-sheet-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.sheet-close {
  position: absolute;
  top: var(--spacing);
  right: var(--spacing);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.sheet-close:hover {
  background: var(--border);
}

/* Search Container */
.search-container {
  padding: 0 var(--spacing) var(--spacing);
  flex-shrink: 0;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field i {
  position: absolute;
  left: 12px;
  color: var(--text-secondary);
  font-size: 16px;
  z-index: 1;
}

.search-field input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--background);
  color: var(--text-primary);
  transition: var(--transition);
}

.search-field input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(65, 255, 59, 0.1);
}

/* =====================================
   21. OPTIONS LIST COMPONENTS
===================================== */
.options-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--spacing) calc(var(--bottom-safe) + var(--spacing));
  -webkit-overflow-scrolling: touch;
}

.option-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  touch-action: manipulation;
}

.option-item:last-child {
  border-bottom: none;
}

.option-item:active {
  background: var(--border-light);
}

.option-item:hover {
  background: rgba(65, 255, 59, 0.05);
}

.option-text {
  flex: 1;
}

.option-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.option-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
}

.option-check {
  color: var(--primary-color);
  font-size: 20px;
  display: none;
  margin-left: var(--spacing);
}

.option-item.selected .option-check {
  display: block;
}

.empty-state {
  text-align: center;
  padding: calc(var(--spacing) * 3);
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 48px;
  color: var(--text-light);
  margin-bottom: var(--spacing);
}

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: var(--spacing);
}

/* =====================================
   22. SAVED LIST COMPONENTS
===================================== */
.saved-list {
  padding: 0;
}

.saved-item {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: var(--spacing);
  padding: var(--spacing);
  box-shadow: var(--shadow);
  transition: var(--transition);
  border-left: 4px solid var(--border);
}

.saved-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.saved-item.synced {
  border-left-color: var(--success-color);
}

.saved-item.pending {
  border-left-color: var(--warning-color);
}

.saved-item.error {
  border-left-color: var(--danger-color);
}

.saved-item-header {
  display: flex;
  justify-content: between;
  align-items: start;
  margin-bottom: 8px;
}

.saved-item-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.saved-item-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 4px 0 8px;
  line-height: 1.4;
}

.saved-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-light);
}

.sync-status {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sync-status.synced {
  color: var(--success-color);
  background: rgba(25, 135, 84, 0.1);
}

.sync-status.pending {
  color: var(--warning-color);
  background: rgba(255, 193, 7, 0.1);
}

.sync-status.error {
  color: var(--danger-color);
  background: rgba(220, 53, 69, 0.1);
}

.saved-item-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-sm:hover {
  background: var(--border-light);
}

.btn-sm.btn-success {
  background: var(--success-color);
  border-color: var(--success-color);
  color: white;
}

.btn-sm.btn-danger {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

/* =====================================
   23. LOADING COMPONENTS
===================================== */
.loading-content {
  text-align: center;
  max-width: 280px;
  padding: calc(var(--spacing) * 2);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-light);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto calc(var(--spacing) * 1.5);
}

.loading-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.loading-content p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: var(--spacing);
}

.loading-progress {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary-color);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.loading {
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border-light);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* =====================================
   24. DETAILED TOAST COMPONENTS
===================================== */
.toast.removing {
  animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast.success .toast-icon {
  background: var(--success-color);
}

.toast.error .toast-icon {
  background: var(--danger-color);
}

.toast.warning .toast-icon {
  background: var(--warning-color);
  color: var(--text-primary);
}

.toast.info .toast-icon {
  background: var(--info-color);
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-wrap: break-word;
}

@keyframes toastOut {
  to {
    transform: translateY(100px);
    opacity: 0;
  }
}

/* =====================================
   25. MODAL COMPONENTS
===================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: none;
}

.modal.show {
  display: block;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--radius);
  min-width: 320px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: var(--spacing);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--border);
}

.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.menu-item {
  padding: 16px var(--spacing);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
  touch-action: manipulation;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:active {
  background: var(--border-light);
}

.menu-item:hover {
  background: rgba(65, 255, 59, 0.05);
}

.menu-item i {
  width: 20px;
  color: var(--text-secondary);
  font-size: 16px;
}

.menu-item span {
  font-size: 16px;
  color: var(--text-primary);
}

/* =====================================
   26. STATE COMPONENTS
===================================== */
.error-state {
  text-align: center;
  padding: calc(var(--spacing) * 3);
  color: var(--text-secondary);
}

.error-state i {
  font-size: 48px;
  color: var(--text-light);
  margin-bottom: var(--spacing);
}

.error-state h3 {
  color: var(--danger-color);
  margin-bottom: 8px;
}

.error-state p {
  margin-bottom: var(--spacing);
}

.success-state {
  text-align: center;
  padding: calc(var(--spacing) * 3);
  color: var(--text-secondary);
}

.success-state i {
  font-size: 48px;
  color: var(--success-color);
  margin-bottom: var(--spacing);
}

.success-state h3 {
  color: var(--success-color);
  margin-bottom: 8px;
}

/* Connection State Indicators */
.connection-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.connection-indicator.online {
  background: rgba(25, 135, 84, 0.1);
  color: var(--success-color);
}

.connection-indicator.offline {
  background: rgba(255, 193, 7, 0.1);
  color: var(--warning-color);
}

.connection-indicator .indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* =====================================
   27. FORM VALIDATION STATES
===================================== */
.form-field.error input,
.form-field.error textarea,
.form-field.error .select-field {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-field.success input,
.form-field.success textarea,
.form-field.success .select-field {
  border-color: var(--success-color);
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
}

.error-message {
  display: block;
  font-size: 12px;
  color: var(--danger-color);
  margin-top: 4px;
}

.success-message {
  display: block;
  font-size: 12px;
  color: var(--success-color);
  margin-top: 4px;
}

.select-field.active i {
  transform: rotate(180deg);
}

/* =====================================
   28. CUSTOM ALERT SYSTEM
===================================== */
.custom-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.custom-alert-overlay.show {
  opacity: 1;
  visibility: visible;
}

.custom-alert-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
}

.custom-alert-content {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.8) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1;
  position: relative;
}

.custom-alert-overlay.show .custom-alert-content {
  transform: scale(1) translateY(0);
}

.alert-header {
  padding: 24px 24px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}

.alert-header.success {
  background: linear-gradient(135deg, var(--success-color), #27ae60);
  color: white;
}

.alert-header.error {
  background: linear-gradient(135deg, var(--danger-color), #e74c3c);
  color: white;
}

.alert-header.warning {
  background: linear-gradient(135deg, var(--warning-color), #f39c12);
  color: white;
}

.alert-header.info {
  background: linear-gradient(135deg, var(--primary-color), #3498db);
  color: white;
}

.alert-header.confirm {
  background: linear-gradient(135deg, #8e44ad, #9b59b6);
  color: white;
}

.alert-header.prompt {
  background: linear-gradient(135deg, #16a085, #1abc9c);
  color: white;
}

.alert-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.alert-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.alert-body {
  padding: 24px;
  text-align: center;
}

.alert-message {
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 16px;
  color: var(--text-secondary);
  white-space: pre-line;
}

.alert-input-container {
  position: relative;
  margin-bottom: 8px;
}

.alert-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.3s ease;
}

.alert-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(65, 255, 59, 0.1);
}

.input-error {
  color: var(--danger-color);
  font-size: 12px;
  margin-top: 4px;
  text-align: left;
}

.alert-actions {
  padding: 16px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.alert-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 100px;
  position: relative;
  overflow: hidden;
}

.alert-btn::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.3s ease, height 0.3s ease;
}

.alert-btn:active::before {
  width: 300px;
  height: 300px;
}

.alert-btn.btn-primary {
  background: var(--primary-color);
  color: var(--text-primary);
}

.alert-btn.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(65, 255, 59, 0.3);
}

.alert-btn.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border);
}

.alert-btn.btn-secondary:hover {
  background: var(--border-light);
  transform: translateY(-2px);
}

.alert-btn.btn-danger {
  background: var(--danger-color);
  color: white;
}

.alert-btn.btn-danger:hover {
  background: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(231, 76, 60, 0.3);
}

.alert-btn.btn-success {
  background: var(--success-color);
  color: white;
}

.alert-btn.btn-success:hover {
  background: #27ae60;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(46, 204, 113, 0.3);
}

.alert-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.alert-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.alert-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.alert-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* =====================================
   29. ADVANCED ANIMATIONS
===================================== */
.bounce-in {
  animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }

  50% {
    transform: scale(1.05);
    opacity: 1;
  }

  70% {
    transform: scale(0.9);
  }

  100% {
    transform: scale(1);
  }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {

  10%,
  90% {
    transform: translateX(-1px);
  }

  20%,
  80% {
    transform: translateX(2px);
  }

  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }

  40%,
  60% {
    transform: translateX(4px);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =====================================
   30. ACCESSIBILITY & PRINT STYLES
===================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.focus-visible {
  outline: 2px solid var(--primary-color) !important;
  outline-offset: 2px !important;
}

@supports (padding: max(0px)) {
  .top-nav {
    padding-top: max(var(--top-safe), var(--spacing));
  }

  .main-content {
    padding-bottom: max(var(--bottom-safe), var(--spacing));
  }

  .options-list {
    padding-bottom: max(calc(var(--bottom-safe) + var(--spacing)), calc(var(--spacing) * 2));
  }
}

@media print {

  .top-nav,
  .bottom-sheet,
  .loading-overlay,
  .toast-container,
  .modal,
  .form-actions {
    display: none !important;
  }

  .screen {
    display: block !important;
    padding: 0;
    box-shadow: none;
  }

  .mobile-form,
  .form-section {
    box-shadow: none;
    border: 1px solid #000;
  }
}

@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  }

  .form-field input:focus,
  .form-field textarea:focus,
  .select-field:focus-within {
    border-width: 3px;
  }

  .btn-primary {
    border: 2px solid var(--text-primary);
  }
}

/* Mobile alert optimizations */
@media (max-width: 480px) {
  .custom-alert-content {
    margin: 20px;
    max-width: none;
    border-radius: 12px;
  }

  .alert-header {
    padding: 20px 20px 12px;
  }

  .alert-icon {
    width: 56px;
    height: 56px;
    font-size: 24px;
    margin-bottom: 12px;
  }

  .alert-title {
    font-size: 18px;
  }

  .alert-body {
    padding: 20px;
  }

  .alert-message {
    font-size: 15px;
  }

  .alert-actions {
    padding: 12px 20px 20px;
    flex-direction: column;
  }

  .alert-btn {
    width: 100%;
    padding: 14px 20px;
  }

}

[data-theme="dark"] .custom-alert-content {
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .alert-input {
  background: var(--surface);
  border-color: var(--border);
}


/* =====================================
   PWA INSTALL POPUP & FLOATING BUTTON
===================================== */
.pwa-install-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.pwa-install-popup.show {
    display: flex !important;
    animation: fadeIn 0.3s ease-out;
}

.pwa-popup-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 0;
    max-width: 380px;
    width: calc(100% - 40px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.pwa-install-popup.show .pwa-popup-content {
    transform: scale(1) translateY(0);
}

.pwa-popup-header {
    text-align: center;
    padding: 32px 24px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    position: relative;
}

.pwa-popup-header .pwa-app-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pwa-popup-header .pwa-app-icon img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
}

.pwa-popup-header h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.pwa-popup-header p {
    font-size: 15px;
    opacity: 0.9;
    line-height: 1.4;
    margin: 0;
}

.pwa-popup-features {
    padding: 24px;
}

.pwa-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.pwa-feature-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pwa-feature-item i {
    width: 20px;
    font-size: 16px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.pwa-feature-item span {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

.pwa-popup-actions {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-btn-install {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    font-family: inherit;
}

.pwa-btn-install:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(113, 193, 109, 0.3);
}

.pwa-btn-dismiss {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.pwa-btn-dismiss:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.pwa-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pwa-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Floating Install Button */
.pwa-float-btn {
    position: fixed;
    bottom: calc(var(--bottom-safe) + 20px);
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1500;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pwa-float-btn.show {
    display: flex;
    animation: bounceIn 0.6s ease-out;
}

.pwa-float-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(113, 193, 109, 0.4);
}

.pwa-float-btn:active {
    transform: scale(0.95);
}

.pwa-float-btn.pulse {
    animation: floatPulse 2s infinite;
}

@keyframes floatPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(113, 193, 109, 0.15);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(113, 193, 109, 0.3);
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .pwa-install-popup {
        padding: 16px;
    }
    
    .pwa-popup-content {
        width: calc(100% - 32px);
        border-radius: 16px;
    }
    
    .pwa-popup-header {
        padding: 24px 20px 20px;
    }
    
    .pwa-popup-header .pwa-app-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 12px;
    }
    
    .pwa-popup-header .pwa-app-icon img {
        width: 50px;
        height: 50px;
    }
    
    .pwa-popup-header h3 {
        font-size: 20px;
    }
    
    .pwa-popup-features {
        padding: 20px;
    }
    
    .pwa-popup-actions {
        padding: 0 20px 20px;
    }
    
    .pwa-float-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
        bottom: calc(var(--bottom-safe) + 16px);
        right: 16px;
    }
}

/* Dark theme support */
[data-theme="dark"] .pwa-popup-content {
    background: var(--surface);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .pwa-float-btn {
    background: var(--primary-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* =====================================
   END OF RESTRUCTURED CSS
===================================== */