@tailwind base;
@tailwind components;
@tailwind utilities;

/* PWA-specific styles */
/* Ensure the app works well in standalone mode */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Hide elements that don't make sense in standalone */
  .browser-only {
    display: none !important;
  }
}

/* iOS PWA styles */
@supports (-webkit-touch-callout: none) {
  .ios-safe-area {
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* Enhanced touch targets for mobile */
@media (pointer: coarse) {
  .card-button,

  /* Placeholder tokens (dynamic announcement placeholders) */
  .placeholder-token {
    display: inline-block;
    background: #e6f9ee;
    color: #0c6e35;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.2;
    border: 1px solid #b6e8c9;
    word-break: break-all;
  }
  /* Highlight placeholders inside manager list */
  .ann-placeholder-highlight {
    background: transparent;
    color: #16a34a !important; /* brighter green for better contrast */
    padding: 0;
    font-weight: 600;
    font-size: 90%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  }
  .btn,
  .btn-secondary,
  .btn-danger {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Larger touch areas for mobile */
  button, input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Improve scrolling on iOS */
.overflow-y-auto {
  -webkit-overflow-scrolling: touch;
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: #DC2626;
  color: white;
  text-align: center;
  padding: 0.5rem;
  z-index: 1000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-indicator.show {
  transform: translateY(0);
}

/* Pull-to-refresh indicator */
.ptr-element {
  height: 0;
  overflow: hidden;
  transition: height 0.3s ease;
  text-align: center;
  padding: 0 1rem;
  background: linear-gradient(to bottom, #f3f4f6, white);
}

.ptr-element.ptr-refresh {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Installation prompt styles */
.install-prompt {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  background: #0C6E35;
  color: white;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.install-prompt.show {
  transform: translateY(0);
}

/* Update notification */
.update-notification {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #0C6E35, #2D8D5A);
  color: white;
  padding: 1rem;
  text-align: center;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.input {
  background-color: white;
  border: 1px solid #0C6E35;
  color: #1A1A1A;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  width: 16rem;
}
.btn {
  background-color: #0C6E35;
  color: white;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: background-color 0.3s ease;
}
.btn:hover {
  background-color: #2D8D5A;
}

.btn-secondary {
  background-color: #6B7280;
  color: white;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: background-color 0.3s ease;
  border: none;
  cursor: pointer;
}
.btn-secondary:hover {
  background-color: #4B5563;
}

.btn-danger {
  background-color: #DC2626;
  color: white;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: background-color 0.3s ease;
  border: none;
  cursor: pointer;
}
.btn-danger:hover {
  background-color: #B91C1C;
}

.card-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e2e8f0;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(147, 51, 234, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-button:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: #cbd5e1;
}

.card-button:hover::before {
  opacity: 1;
}

.card-button:active {
  transform: translateY(-2px);
}
.card-button img {
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.5rem;
}
#modal input,
#modal textarea,
#modal select {
  width: 100%;
  border: 1px solid #0C6E35;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}
.loader {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #0C6E35;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.home-dot.active {
  background-color: #0C6E35;
}

.home-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #D7F9D0;
  cursor: pointer;
}

/* Enhanced PWA Styles */
.fab-button {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.fab-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.fab-action {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fab-action:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* PWA Install Prompt Animation */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.pwa-install-slide-in {
  animation: slideInRight 0.3s ease-out;
}

.pwa-install-slide-out {
  animation: slideOutRight 0.3s ease-in;
}

/* Offline Banner Styles */
#admin-offline-banner {
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Keyboard Shortcuts Guide */
#admin-shortcuts-guide,
#pwa-shortcuts {
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Share Button Styles */
.share-btn {
  background: linear-gradient(135deg, #0C6E35 0%, #065F2F 100%);
  border: none;
  box-shadow: 0 2px 4px rgba(12, 110, 53, 0.2);
  transition: all 0.2s ease;
}

.share-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(12, 110, 53, 0.3);
}

/* PWA Specific Media Queries */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .fab-container {
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
  
  #admin-shortcuts-guide,
  #pwa-shortcuts {
    bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* Enhanced Button Styles for PWA */
.btn-pwa-primary {
  background: linear-gradient(135deg, #0C6E35 0%, #065F2F 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 14px 0 rgba(12, 110, 53, 0.3);
}

.btn-pwa-primary:hover {
  background: linear-gradient(135deg, #065F2F 0%, #0C6E35 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(12, 110, 53, 0.4);
}

/* Loading States for PWA */
.pwa-loading {
  position: relative;
  overflow: hidden;
}

.pwa-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Touch-friendly styles for mobile PWA */
@media (max-width: 768px) {
  .fab-button {
    width: 56px;
    height: 56px;
  }
  
  .fab-action {
    width: 48px;
    height: 48px;
  }
  
  button, .btn {
    min-height: 44px; /* iOS recommendation for touch targets */
    min-width: 44px;
  }
}

/* Mobile-only modal UX fixes */
@media (max-width: 640px) {
  /* Ensure the main modal content scrolls within viewport and leaves space for actions */
  #modal #modal-content {
    max-height: 90vh;
    overflow-y: auto;
    padding-bottom: 4rem; /* avoid action buttons getting cut off at bottom */
  }

  /* Keep the close X always visible and tappable on mobile */
  #modal #close-modal {
    position: fixed;
    top: 12px;
    right: 24px;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 9999px;
    padding: 8px 12px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  /* Make filter/toolbars wrap instead of overflow off-screen */
  #modal .flex {
    flex-wrap: wrap;
  }

  /* Prevent pagination rows from overlapping adjacent buttons */
  #modal [id$="-pagination"],
  #modal #member-pagination,
  #modal #polls-pagination,
  #modal #member-polls-pagination,
  #modal #artist-pagination,
  #modal #attendance-pagination,
  #modal #log-pagination {
    margin-bottom: 0.5rem;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .fab-button,
  .fab-action {
    border: 2px solid currentColor;
  }
  
  .btn-pwa-primary {
    border: 2px solid #0C6E35;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .fab-button,
  .fab-action,
  .btn-pwa-primary,
  #admin-offline-banner,
  .pwa-install-slide-in,
  .pwa-install-slide-out {
    animation: none;
    transition: none;
  }
  
  .fab-button:hover,
  .fab-action:hover,
  .btn-pwa-primary:hover {
    transform: none;
  }
}

/* Checkbox styling fixes */
input[type="checkbox"] {
  margin-right: 0.5rem;
  margin-left: 0;
  width: 1rem;
  height: 1rem;
  accent-color: #0C6E35;
  cursor: pointer;
}

/* Ensure proper spacing for checkbox labels */
label.inline-flex {
  gap: 0.5rem !important;
  align-items: center;
}

label.inline-flex input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}

#modal input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
}

/* Custom poll option check styles */
.custom-check { position: relative; }
.custom-check .checkmark { position: absolute; }
label .select-text { line-height: 1.2; }

input[type="radio"] {
  margin: 0;              /* remove browser default + your forced margin */
  width: 1rem;
  height: 1rem;
  accent-color: #0C6E35;
  cursor: pointer;
  flex-shrink: 0;          /* prevents radio from shrinking in flex */
}

/* Mobile Dashboard Fixes */
@media (max-width: 768px) {
  /* Dashboard header - prevent button wrapping and horizontal scroll */
  #dashboard .relative.flex {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  /* Move welcome message to top on mobile */
  #dashboard h2 {
    position: static !important;
    transform: none !important;
    order: -1;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    white-space: normal;
  }
  
  /* Buttons container - wrap and center */
  #dashboard .flex.gap-3:first-child {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  
  /* Right side buttons container */
  #dashboard .flex.gap-3:last-child {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    order: 1;
  }
  
  /* Make dashboard buttons smaller on mobile */
  #dashboard .flex.gap-3 button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-width: auto;
  }
  
  /* Make dashboard button text and icons smaller */
  #dashboard .flex.gap-3 button svg {
    width: 0.875rem;
    height: 0.875rem;
  }
  
  /* Tool grid - 2 columns instead of 3 */
  #tool-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }
  
  /* Make tool cards smaller on mobile */
  #tool-grid .card-button {
    padding: 1.5rem 1rem;
  }
  
  /* Make tool card icons smaller */
  #tool-grid .card-button .text-4xl {
    font-size: 2rem;
  }
  
  /* Make tool card text smaller */
  #tool-grid .card-button .font-semibold {
    font-size: 0.875rem;
    margin-top: 0.5rem;
  }
  
  /* Remove horizontal padding to prevent scroll */
  #dashboard {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Ensure no horizontal overflow */
  #dashboard * {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Full-screen modal styles */
.fullscreen-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  z-index: 9999 !important;
}

.fullscreen-modal .modal-content {
  height: 100% !important;
  border-radius: 0 !important;
}

.fullscreen-modal .modal-body {
  height: calc(100% - 120px) !important;
  overflow-y: auto;
}

.fullscreen-modal .modal-header {
  position: sticky;
  top: 0;
  background: white;
  z-index: 10000;
  border-bottom: 1px solid #e5e7eb;
}

/* Progress bar styles */
.progress-container {
  margin-top: 0.5rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  width: 0%;
  transition: width 0.3s ease;
}

/* Enhanced Typography for Admin Content Display */
.admin-content p { margin-bottom: 12px; }
.admin-content h1, .admin-content h2, .admin-content h3, 
.admin-content h4, .admin-content h5, .admin-content h6 {
  margin: 16px 0 12px 0;
  font-weight: 600;
}
.admin-content ul, .admin-content ol { 
  margin-bottom: 12px; 
  padding-left: 20px; 
}
.admin-content blockquote {
  border-left: 3px solid #0C6E35;
  padding-left: 12px;
  margin: 12px 0;
  font-style: italic;
  background: #f8f9fa;
  padding: 12px;
  border-radius: 4px;
}

/* Custom rainbow gradient for FRESH badges */
.rainbow-gradient {
  background: linear-gradient(90deg,
    #ff0000 0%,
    #ffa500 16.67%,
    #ffff00 33.33%,
    #008000 50%,
    #0000ff 66.67%,
    #4b0082 83.33%,
    #ee82ee 100%);
  color: #1f2937; /* Dark text for contrast */
}

/* Holographic foil effect for FRESH badge chips */
.holographic-foil {
  background: linear-gradient(135deg,
    #ff8cf0 0%,
    #7ee8fa 16.67%,
    #4ade80 33.33%,
    #22d3ee 50%,
    #facc15 66.67%,
    #c084fc 83.33%,
    #ff8cf0 100%) !important;
  background-size: 200% 200% !important;
  animation: holographic-shimmer 3s ease-in-out infinite !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 15px rgba(255, 140, 240, 0.35) !important;
  position: relative !important;
}

.holographic-foil * {
  color: #fff !important;
}

@keyframes holographic-shimmer {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}