/* ============================================
   AWP Input Enhancements Styles v1.0
   AnchorWellPress — Universal UI Enhancements for All Tools
   Last Updated: 2026-03-18

   USAGE: Add <link rel="stylesheet" href="/css/awp-input-enhancements.css">
   after awp-shared.css
   ============================================ */

/* --- 1. ICON BUTTON BASE --- */
.awp-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  background: var(--cloud, #F1F5F9);
  color: var(--slate, #64748B);
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-md, 8px);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.awp-btn-icon:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: var(--teal, #2E8B8B);
  color: var(--teal, #2E8B8B);
}

.awp-btn-icon:active:not(:disabled) {
  transform: scale(0.95);
}

.awp-btn-icon:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.awp-btn-icon:focus-visible {
  outline: 2px solid var(--teal, #2E8B8B);
  outline-offset: 2px;
}

.awp-btn-text {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
}

@media (min-width: 640px) {
  .awp-btn-icon .awp-btn-text {
    display: inline;
  }
}

/* --- 2. DICTATION BUTTON (FEATURE 1) --- */
.awp-input-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.awp-dictation-btn {
  background: var(--cloud, #F1F5F9);
  color: var(--slate, #64748B);
}

.awp-dictation-btn:hover:not(:disabled) {
  background: #e2e8f0;
  color: var(--teal, #2E8B8B);
}

.awp-dictation-btn.awp-listening {
  background: #fee2e2;
  color: #dc2626;
  animation: pulse-listen 1.5s ease-in-out infinite;
  border-color: #fca5a5;
}

@keyframes pulse-listen {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
  }
}

/* Tooltip styling */
.awp-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-deep, #0F2440);
  color: var(--white, #FFFFFF);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-bottom: 0.5rem;
  z-index: 1000;
}

.awp-btn-icon:hover .awp-tooltip {
  opacity: 1;
}

/* --- 3. TEXT-TO-SPEECH BUTTON (FEATURE 2) --- */
.awp-result-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.awp-speak-btn {
  background: var(--cloud, #F1F5F9);
  color: var(--teal, #2E8B8B);
}

.awp-speak-btn:hover:not(:disabled) {
  background: rgba(46, 139, 139, 0.1);
  border-color: var(--teal, #2E8B8B);
}

.awp-speak-btn.awp-speaking {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
  border-color: #86efac;
  animation: pulse-speak 0.8s ease-in-out infinite;
}

@keyframes pulse-speak {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* --- 4. FONT SIZE CONTROLS (FEATURE 3) --- */
.awp-font-controls {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--white, #FFFFFF);
  padding: 0.75rem;
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 999;
}

.awp-font-controls .awp-btn-icon {
  padding: 0.5rem;
  min-width: 40px;
  min-height: 40px;
  background: transparent;
  border: none;
}

.awp-font-controls .awp-btn-icon:hover:not(:disabled) {
  background: var(--cloud, #F1F5F9);
  border-color: var(--teal, #2E8B8B);
}

/* --- 5. HIGH CONTRAST MODE (FEATURE 4) --- */
.awp-contrast-btn {
  background: var(--cloud, #F1F5F9);
  color: var(--slate, #64748B);
}

.awp-contrast-btn.awp-contrast-active {
  background: rgba(27, 58, 92, 0.1);
  color: var(--navy, #1B3A4B);
  border-color: var(--navy, #1B3A4B);
}

.awp-contrast-btn:hover:not(:disabled) {
  background: #e2e8f0;
  color: var(--navy, #1B3A4B);
}

/* High contrast theme */
body.awp-high-contrast {
  --navy: #000000;
  --navy-deep: #000000;
  --teal: #0066CC;
  --teal-light: #0066CC;
  --slate: #000000;
  --cloud: #FFFFFF;
  --white: #FFFFFF;
  --coral: #CC0000;
  background: #FFFFFF !important;
  color: #000000 !important;
}

body.awp-high-contrast textarea,
body.awp-high-contrast input[type="text"],
body.awp-high-contrast input[type="email"],
body.awp-high-contrast input[type="number"],
body.awp-high-contrast input[type="tel"],
body.awp-high-contrast input[type="url"],
body.awp-high-contrast select {
  background: #FFFFFF !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
}

body.awp-high-contrast textarea:focus,
body.awp-high-contrast input:focus,
body.awp-high-contrast select:focus {
  border-color: #0066CC !important;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2) !important;
}

body.awp-high-contrast .result-box {
  background: #FFFFFF !important;
  border: 2px solid #000000 !important;
  color: #000000 !important;
}

body.awp-high-contrast .result-content {
  color: #000000 !important;
}

body.awp-high-contrast a {
  color: #0066CC !important;
  text-decoration: underline !important;
}

body.awp-high-contrast .btn-primary {
  background: #0066CC !important;
  color: #FFFFFF !important;
  border: 2px solid #0066CC !important;
}

body.awp-high-contrast .awp-btn-icon {
  background: #FFFFFF !important;
  border: 2px solid #000000 !important;
  color: #000000 !important;
}

body.awp-high-contrast .awp-font-controls {
  background: #FFFFFF !important;
  border: 2px solid #000000 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

/* --- 6. ENHANCED LOADING STATE (FEATURE 5) --- */
.awp-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  gap: 1rem;
  padding: 2rem;
}

.awp-loading-overlay.awp-show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

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

.awp-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.awp-spinner-circle {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(46, 139, 139, 0.2);
  border-top-color: var(--teal, #2E8B8B);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.awp-loading-text {
  color: var(--white, #FFFFFF);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

.awp-loading-timer {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  min-width: 50px;
}

.awp-loading-message {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  text-align: center;
  max-width: 300px;
}

.awp-btn-cancel {
  margin-top: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--navy, #1B3A4B);
  border: none;
  border-radius: var(--radius-md, 8px);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body, 'Inter', sans-serif);
}

.awp-btn-cancel:hover {
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.awp-btn-cancel:focus-visible {
  outline: 2px solid var(--white, #FFFFFF);
  outline-offset: 2px;
}

/* --- 7. ERROR RETRY BUTTON (FEATURE 6) --- */
.awp-try-again-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--teal, #2E8B8B), #3AAFAF);
  color: var(--white, #FFFFFF);
  border: none;
  border-radius: var(--radius-md, 8px);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body, 'Inter', sans-serif);
}

.awp-try-again-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 139, 139, 0.3);
}

.awp-try-again-btn:active {
  transform: translateY(0);
}

.awp-try-again-btn:focus-visible {
  outline: 2px solid var(--teal, #2E8B8B);
  outline-offset: 2px;
}

.awp-try-again-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* --- 8. ACCESSIBILITY & RESPONSIVE --- */
@media (max-width: 768px) {
  .awp-font-controls {
    bottom: 1rem;
    right: 1rem;
    gap: 0.25rem;
    padding: 0.5rem;
  }

  .awp-loading-overlay {
    padding: 1.5rem;
  }

  .awp-spinner-circle {
    width: 40px;
    height: 40px;
    border-width: 3px;
  }

  .awp-loading-text {
    font-size: 1rem;
  }

  .awp-tooltip {
    position: static;
    opacity: 0;
    pointer-events: none;
    margin: 0;
    transform: none;
  }

  .awp-input-controls,
  .awp-result-controls {
    gap: 0.4rem;
  }
}

@media (max-width: 480px) {
  .awp-font-controls {
    bottom: 0.75rem;
    right: 0.75rem;
    padding: 0.4rem;
  }

  .awp-btn-icon {
    min-width: 40px;
    min-height: 40px;
    padding: 0.4rem;
  }

  .awp-loading-message {
    font-size: 0.85rem;
  }
}

/* Touch-friendly: ensure minimum 44px touch targets */
@media (hover: none) and (pointer: coarse) {
  .awp-btn-icon {
    min-width: 48px;
    min-height: 48px;
  }

  .awp-tooltip {
    display: none;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .awp-dictation-btn.awp-listening {
    animation: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
  }

  .awp-speak-btn.awp-speaking {
    animation: none;
    opacity: 0.85;
  }

  .awp-spinner-circle {
    animation: none;
    border-top-color: transparent;
    border-right-color: var(--teal, #2E8B8B);
  }

  .awp-loading-overlay {
    animation: none;
  }

  .awp-btn-icon,
  .awp-try-again-btn {
    transition: none;
  }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  .awp-tooltip {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
  }

  .awp-font-controls {
    background: #1e293b;
    border: 1px solid #334155;
  }

  .awp-loading-overlay {
    background: rgba(0, 0, 0, 0.7);
  }

  .awp-btn-cancel {
    background: #334155;
    color: #f1f5f9;
  }

  .awp-btn-cancel:hover {
    background: #475569;
  }
}
