/**
 * Responsive styles - Mobile header, media queries
 */

/* --------------------------------------------------------------------------
   Mobile Header
   -------------------------------------------------------------------------- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  z-index: 50;
  padding: 0 12px;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}

.mobile-menu-btn:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.mobile-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.mobile-logo-text {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--primary-600);
  letter-spacing: -0.025em;
}

.mobile-user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-user-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.mobile-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-400) 0%, var(--primary-500) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.8125rem;
}

.mobile-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 100;
}

.mobile-user-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mobile-user-info {
  padding: 12px 16px;
}

.mobile-user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-900);
}

.mobile-user-role {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.mobile-user-divider {
  height: 1px;
  background: var(--gray-100);
}

.mobile-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--red-600);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.mobile-logout-btn:hover {
  background: var(--red-50);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Header Actions
   -------------------------------------------------------------------------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Language Toggle
   -------------------------------------------------------------------------- */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  color: var(--gray-700);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-toggle:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.lang-flag {
  font-size: 1rem;
  line-height: 1;
}

.lang-code {
  text-transform: uppercase;
}

/* Mobile language toggle */
.mobile-lang-toggle {
  border-color: transparent;
  background: transparent;
  color: var(--gray-600);
}

.mobile-lang-toggle:hover {
  background: var(--gray-100);
  border-color: transparent;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Show mobile header */
  .mobile-header {
    display: flex;
  }

  .mobile-overlay {
    display: block;
  }

  /* Sidebar as slide-out drawer */
  .sidebar {
    top: 56px;
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Overlay starts below mobile header */
  .mobile-overlay {
    top: 56px;
  }

  /* Main content adjustments */
  .main {
    margin-left: 0;
    padding-top: 56px;
  }

  .main-header {
    position: relative;
    top: 0;
  }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  /* Cards grid - single column, no horizontal stacking */
  .cards-grid {
    grid-template-columns: 1fr;
    min-width: 0; /* Prevent grid blowout */
  }

  /* Main content padding */
  .main-content {
    padding-left: 1rem;
    padding-right: 1rem;
    min-width: 0; /* Prevent content blowout */
    overflow-x: hidden;
  }

  .main-header {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Header row stacks on mobile */
  .header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  /* Filters - full width, stacked */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .search-group {
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select {
    width: 100%;
    min-width: unset;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
  }

  /* Mobile sticky filters - account for mobile header */
  .filters-bar {
    top: 64px; /* Below mobile header with breathing room */
    background: var(--gray-50);
  }

  /* Mobile card sizing - use viewport width */
  .card-stack-container {
    max-width: calc(100vw - 2rem);
  }

  .crop-card.stacked {
    flex: 0 0 calc(100vw - 2rem);
    width: calc(100vw - 2rem);
  }

  /* Hide sidebar footer user card on mobile (shown in mobile header instead) */
  .sidebar-footer {
    display: none;
  }

  /* Hide language toggle from header actions (shown in mobile header instead) */
  .header-actions .lang-toggle {
    display: none;
  }

  /* Hide filter spacer on mobile (not needed with column layout) */
  .filter-spacer {
    display: none;
  }

  /* Toast container mobile adjustments */
  .toast-container {
    left: 1rem;
    right: 1rem;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }
}

@media (max-width: 480px) {
  /* Single column stats on very small screens */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  /* Smaller page title */
  .page-title {
    font-size: 1.25rem;
  }

  .page-subtitle {
    font-size: 0.8125rem;
  }

  /* Tighter card padding */
  .crop-card-header {
    padding: 1rem 1rem 0;
  }

  .crop-card-body {
    padding: 0 1rem;
  }

  .crop-card-footer {
    padding: 0.875rem 1rem;
  }
}
