:root {
  --primary-color: #1b5e20;
  --primary-hover: #2e7d32;
  --primary-light: #e8f5e9;
  --accent-color: #388e3c;
  --dark-bg: #0c1a11;
  --dark-surface: #14281a;
  --light-bg: #f4f6f4;
  --light-surface: #ffffff;
  --text-dark: #1b2e21;
  --text-light: #f5f5f5;
  --text-muted: #667c6b;
  --border-color: #e1e8e2;
  --shadow-sm: 0 2px 6px rgba(27, 94, 32, 0.06);
  --shadow-md: 0 10px 24px rgba(27, 94, 32, 0.09);
  --shadow-lg: 0 20px 40px rgba(27, 94, 32, 0.14);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
}

#wreath-fundraiser-app-root {
  font-family: var(--font-family);
  background-color: var(--light-bg);
  color: var(--text-dark);
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  margin: 0;
  padding: 0;
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Enable smooth scrolling on customer storefront view */
#wreath-fundraiser-app-root.wreath-customer-view {
  min-height: 100vh;
  min-height: 100dvh;
  height: auto !important;
  overflow-y: auto !important;
  overflow-x: hidden;
}

/* Override html and body scroll restrictions from WP themes */
html.wreath-scrollable-body, body.wreath-scrollable-body {
  overflow: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

#wreath-fundraiser-app-root * {
  box-sizing: border-box;
  font-family: var(--font-family);
}

/* Header Component */
.wreath-header {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
  padding: clamp(14px, 3vw, 24px) clamp(16px, 4vw, 36px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.wreath-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  transform: rotate(-30deg);
  pointer-events: none;
}

.wreath-header h1 {
  margin: 0;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 700;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.wreath-header-meta {
  font-size: clamp(12px, 2.5vw, 14px);
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Main App Shell Layout */
.wreath-app-container {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: calc(100vh - 72px);
  min-height: calc(100dvh - 72px);
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Sidebar & Navigation */
.wreath-sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--light-surface);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}

.wreath-main-content {
  flex: 1;
  padding: clamp(16px, 4vw, 36px);
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--light-bg);
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  box-sizing: border-box;
  min-width: 0;
}

/* Navigation Items */
.wreath-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  min-height: 44px;
}

.wreath-nav-item:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.wreath-nav-item.active {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 14px rgba(27, 94, 32, 0.25);
}

.wreath-nav-item i {
  font-size: 18px;
}

/* Auth / Login Container */
.wreath-auth-card {
  width: 92%;
  max-width: 440px;
  margin: clamp(20px, 6vw, 60px) auto;
  background: var(--light-surface);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 40px);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.wreath-auth-card:hover {
  box-shadow: var(--shadow-lg);
}

.wreath-auth-card h2 {
  margin-top: 0;
  font-size: clamp(20px, 4vw, 24px);
  color: var(--primary-color);
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

/* Forms & Controls */
.wreath-form-group {
  margin-bottom: 20px;
  position: relative;
}

.wreath-form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.wreath-input, .wreath-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  background-color: var(--light-bg);
  color: var(--text-dark);
  min-height: 46px;
}

.wreath-input:focus, .wreath-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.12);
  background-color: var(--light-surface);
}

.wreath-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 24px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  gap: 8px;
  min-height: 46px;
}

.wreath-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(27, 94, 32, 0.2);
}

.wreath-btn-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.wreath-btn-secondary:hover {
  background-color: var(--primary-light);
}

.wreath-btn-danger {
  background-color: #c62828;
  color: white;
}

.wreath-btn-danger:hover {
  background-color: #b71c1c;
}

.wreath-error {
  color: #c62828;
  font-size: 14px;
  background-color: #ffebee;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  border: 1px solid #ffcdd2;
}

/* Stats Cards Grid */
.wreath-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: clamp(14px, 3vw, 24px);
  margin-bottom: 28px;
}

.wreath-stat-card {
  background: var(--light-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}

.wreath-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.wreath-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.wreath-stat-value {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800;
  color: var(--primary-color);
}

/* Products Catalog Grid */
.wreath-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(16px, 3vw, 28px);
  margin-bottom: 30px;
}

.wreath-product-card {
  background: var(--light-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.wreath-product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.wreath-product-img {
  height: 180px;
  width: 100%;
  object-fit: cover;
  background-color: var(--border-color);
  transition: var(--transition);
}

.wreath-product-card:hover .wreath-product-img {
  transform: scale(1.04);
}

.wreath-product-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.wreath-product-name {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--text-dark);
}

.wreath-product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-color);
  margin-bottom: 12px;
}

.wreath-product-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
  flex: 1;
}

.wreath-qty-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--light-bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border-color);
}

.wreath-qty-btn {
  background: var(--light-surface);
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-dark);
}

.wreath-qty-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.wreath-qty-val {
  font-size: 16px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  color: var(--text-dark);
}

/* Responsive Table Wrappers */
.wreath-table-card {
  background: var(--light-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
  width: 100%;
}

.wreath-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.wreath-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 540px;
}

.wreath-table th, .wreath-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.wreath-table th {
  background-color: var(--light-bg);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.wreath-table tr:last-child td {
  border-bottom: none;
}

.wreath-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
}

.wreath-badge-paid {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.wreath-badge-unpaid {
  background-color: #fff8e1;
  color: #f57f17;
}

/* Delivery Map Container */
.wreath-map-container {
  height: clamp(340px, 50vh, 560px);
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.leaflet-container {
  font-family: var(--font-family) !important;
}

/* Floating Map Search Overlay */
.wreath-map-search-wrapper {
  position: absolute;
  top: 14px;
  left: 60px;
  z-index: 1000;
  width: 320px;
  max-width: calc(100% - 80px);
}

.wreath-map-search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  background: var(--light-surface);
  color: var(--text-dark);
  outline: none;
  transition: var(--transition);
}

.wreath-map-search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 12px rgba(46, 125, 50, 0.35);
}

.wreath-map-search-dropdown {
  position: absolute;
  top: 108%;
  left: 0;
  width: 100%;
  background: var(--light-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1001;
  display: none;
}

.wreath-map-search-item {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  transition: var(--transition);
}

.wreath-map-search-item:last-child {
  border-bottom: none;
}

.wreath-map-search-item:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

/* Modals & Overlays */
.wreath-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(12, 26, 17, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
}

.wreath-modal {
  background: var(--light-surface);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 5vw, 36px);
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

/* Shift Tracking Widget */
.wreath-shift-widget {
  background: var(--light-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.wreath-shift-widget.active {
  border-color: #2e7d32;
  background: var(--primary-light);
}

.wreath-pulse-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2e7d32;
  margin-right: 8px;
  animation: wreath-pulse 1.3s infinite alternate;
}

@keyframes wreath-pulse {
  0% { transform: scale(0.85); opacity: 0.5; }
  100% { transform: scale(1.35); opacity: 1; }
}

/* Charts Layout Grid */
.wreath-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 25px);
  margin-bottom: 25px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.wreath-chart-card {
  background: var(--light-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Dark Mode Overrides */
#wreath-fundraiser-app-root.wreath-dark-mode {
  --light-bg: #0c1a11;
  --light-surface: #14281a;
  --text-dark: #f5f5f5;
  --text-muted: #8fa896;
  --border-color: #233e2a;
  --primary-light: #1b3522;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.45);
}

#wreath-fundraiser-app-root.wreath-dark-mode #wreath-delivery-map-canvas {
  filter: brightness(0.85) contrast(1.1);
}

/* Theme Toggle Button */
.wreath-dark-mode-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dark);
  font-size: 18px;
  transition: var(--transition);
}

.wreath-dark-mode-toggle:hover {
  background: var(--primary-light);
  color: var(--primary-color);
  transform: rotate(12deg);
}

/* -------------------------------------------------------------
   RESPONSIVE DESIGN & MOBILE OPTIMIZATION (iPhone, Android, iPad)
   ------------------------------------------------------------- */

/* Global Mobile Guard */
#wreath-fundraiser-app-root img,
#wreath-fundraiser-app-root svg,
#wreath-fundraiser-app-root canvas {
  max-width: 100%;
  height: auto;
}

#wreath-fundraiser-app-root input,
#wreath-fundraiser-app-root select,
#wreath-fundraiser-app-root textarea {
  max-width: 100%;
  box-sizing: border-box;
}

/* Tablet & Mobile (< 900px) */
@media (max-width: 900px) {
  .wreath-app-container {
    flex-direction: column;
    width: 100%;
    min-height: auto;
  }

  .wreath-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 99;
    background: var(--light-surface);
  }

  .wreath-nav-item {
    padding: 10px 16px;
    font-size: 13.5px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .wreath-main-content {
    padding: 18px 14px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .wreath-charts-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .wreath-site-navbar {
    padding: 14px 16px !important;
    gap: 12px;
  }

  .wreath-site-navbar nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 12px !important;
  }
}

/* Mobile Phones (< 650px) */
@media (max-width: 650px) {
  /* Public Header */
  .wreath-site-navbar {
    padding: 12px 14px !important;
  }

  .wreath-site-navbar h1 {
    font-size: 18px !important;
  }

  /* App Logged-In Header */
  .wreath-header {
    flex-direction: column;
    align-items: stretch !important;
    padding: 14px 16px !important;
    gap: 10px;
  }

  .wreath-header h1 {
    font-size: 18px !important;
    text-align: left;
    white-space: normal !important;
  }

  .wreath-header-meta {
    width: 100%;
    font-size: 12px;
    justify-content: space-between;
  }

  /* Hero & Landing */
  section {
    padding: 30px 14px !important;
  }

  .wreath-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .wreath-stat-card {
    padding: 14px !important;
  }

  .wreath-stat-value {
    font-size: 20px !important;
  }

  /* Grids & Cards */
  .wreath-products-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  #section-mission > div {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  #section-portal-login {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  #section-impact > div {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  /* Shift Widget */
  .wreath-shift-widget {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
    padding: 14px !important;
  }

  .wreath-shift-widget button {
    width: 100% !important;
  }

  /* Modals - Perfect Frame Fit */
  .wreath-modal-overlay {
    padding: 10px !important;
    align-items: center;
  }

  .wreath-modal {
    width: 95% !important;
    max-width: 95% !important;
    padding: 20px 16px !important;
    max-height: 88vh !important;
    border-radius: var(--radius-md) !important;
  }

  .wreath-modal h3 {
    font-size: 17px !important;
  }

  /* Forms & Buttons - Optimized for touch */
  .wreath-form-group {
    margin-bottom: 14px !important;
  }

  .wreath-input, .wreath-select {
    font-size: 16px !important; /* 16px prevents unwanted iOS Safari zoom on focus */
    padding: 12px 14px !important;
    min-height: 44px !important; /* Minimum touch target size standard */
  }

  .wreath-btn {
    font-size: 15px !important;
    padding: 12px 18px !important;
    min-height: 44px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Tables with responsive horizontal swipe hint */
  .wreath-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
  }

  .wreath-table th, .wreath-table td {
    padding: 10px 12px !important;
    font-size: 12.5px !important;
    white-space: nowrap;
  }

  /* Delivery Map Canvas */
  #wreath-delivery-map-canvas, #leaflet-map-element {
    height: 380px !important;
    border-radius: var(--radius-sm) !important;
  }

  .wreath-map-search-wrapper {
    left: 8px !important;
    top: 8px !important;
    width: calc(100% - 16px) !important;
    max-width: 100% !important;
  }
}

/* Extra Small Phones (< 380px - iPhone SE / 5 / Galaxy Fold) */
@media (max-width: 380px) {
  .wreath-stats-grid {
    grid-template-columns: 1fr !important;
  }

  #section-impact > div {
    grid-template-columns: 1fr !important;
  }

  .wreath-auth-card {
    padding: 16px !important;
  }

  .wreath-site-navbar h1 {
    font-size: 16px !important;
  }
}

/* Public Website Header Navbar Styling */
.wreath-site-navbar a:hover {
  opacity: 0.85;
  text-decoration: underline !important;
}

/* Print Styles for Door Hangers and Supplier PO Summaries */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .no-print, header, footer, .wreath-site-navbar {
    display: none !important;
  }
}
