/**
 * KTPA Notification System Styles
 *
 * Provides comprehensive styling for:
 * - Success notifications (green)
 * - Info notifications (blue)
 * - Warning notifications (yellow)
 * - Error notifications (red)
 * - Persistent banners
 * - Micro-indicators (saving/saved)
 *
 * Design: Modern, accessible, mobile-responsive
 */

/* === BASE NOTIFICATION STYLES === */

.ktpa-notification {
  padding: 16px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease-out;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  position: relative;
  z-index: 1000;
}

.ktpa-notification-visible {
  opacity: 1;
  transform: translateY(0);
}

.ktpa-notification-exit {
  opacity: 0;
  transform: translateY(-10px);
}

/* === NOTIFICATION TYPES === */

/* Success (Green) */
.ktpa-notification-success {
  background: #D1E7DD;
  border: 1px solid #A3CFBB;
  border-left: 4px solid #0F5132;
  color: #0F5132;
}

/* Info (Blue) */
.ktpa-notification-info {
  background: #CFE2FF;
  border: 1px solid #9EC5FE;
  border-left: 4px solid #084298;
  color: #084298;
}

/* Warning (Yellow) */
.ktpa-notification-warning,
.ktpa-notification-persistent-banner {
  background: #FFF3CD;
  border: 1px solid #FFE69C;
  border-left: 4px solid #664D03;
  color: #664D03;
}

/* Error (Red) */
.ktpa-notification-error {
  background: #F8D7DA;
  border: 1px solid #F1AEB5;
  border-left: 4px solid #842029;
  color: #842029;
}

/* === NOTIFICATION CONTENT === */

.ktpa-notification-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}

.ktpa-notification-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ktpa-notification-message {
  font-size: 1rem;
  line-height: 1.5;
  margin: 0;
}

.ktpa-notification-link {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
  transition: opacity 0.2s;
}

.ktpa-notification-link:hover {
  opacity: 0.8;
  text-decoration: none;
}

/* === NOTIFICATION ACTIONS === */

.ktpa-notification-action,
.ktpa-notification-retry {
  background: rgba(0, 0, 0, 0.1);
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: background 0.2s;
  color: inherit;
  font-family: inherit;
}

.ktpa-notification-action:hover,
.ktpa-notification-retry:hover {
  background: rgba(0, 0, 0, 0.2);
}

.ktpa-notification-action:active,
.ktpa-notification-retry:active {
  transform: translateY(1px);
}

.ktpa-notification-dismiss {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
  color: inherit;
  flex-shrink: 0;
  line-height: 1;
  font-weight: 600;
}

.ktpa-notification-dismiss:hover {
  background: rgba(0, 0, 0, 0.1);
}

.ktpa-notification-dismiss:active {
  transform: scale(0.95);
}

/* === MICRO-INDICATOR (MINIMAL FEEDBACK) === */

.ktpa-save-indicator {
  position: fixed;
  top: 80px;
  right: 20px;
  font-size: 0.875rem;
  padding: 6px 14px;
  border-radius: 16px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.ktpa-save-indicator.saving {
  background: #E7F3FF;
  color: #0066CC;
  border: 1px solid #9EC5FE;
}

.ktpa-save-indicator.saved {
  background: #D1E7DD;
  color: #0F5132;
  border: 1px solid #A3CFBB;
}

/* Pulse animation for "Saving..." */
.ktpa-save-indicator.saving::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 8px;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
  transform: translateY(-50%);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  50% {
    opacity: 0.5;
    transform: translateY(-50%) scale(1.2);
  }
}

/* === ACCESSIBILITY === */

/* Focus styles for keyboard navigation */
.ktpa-notification-action:focus,
.ktpa-notification-retry:focus,
.ktpa-notification-dismiss:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .ktpa-notification {
    border-width: 2px;
  }

  .ktpa-notification-success {
    background: #FFFFFF;
    color: #000000;
    border-color: #0F5132;
  }

  .ktpa-notification-info {
    background: #FFFFFF;
    color: #000000;
    border-color: #084298;
  }

  .ktpa-notification-warning {
    background: #FFFFFF;
    color: #000000;
    border-color: #664D03;
  }

  .ktpa-notification-error {
    background: #FFFFFF;
    color: #000000;
    border-color: #842029;
  }
}

/* === MOBILE RESPONSIVE === */

@media (max-width: 768px) {
  .ktpa-notification {
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.9375rem;
  }

  .ktpa-notification-icon {
    font-size: 1.25rem;
  }

  .ktpa-notification-message {
    font-size: 0.875rem;
  }

  .ktpa-notification-action,
  .ktpa-notification-retry {
    padding: 5px 10px;
    font-size: 0.8125rem;
  }

  .ktpa-notification-dismiss {
    font-size: 1.125rem;
    padding: 2px 6px;
  }

  .ktpa-save-indicator {
    top: 60px;
    right: 10px;
    font-size: 0.75rem;
    padding: 4px 10px;
  }
}

/* Small mobile screens */
@media (max-width: 480px) {
  .ktpa-notification {
    padding: 10px 12px;
    gap: 8px;
  }

  .ktpa-notification-icon {
    font-size: 1.125rem;
  }

  .ktpa-notification-message {
    font-size: 0.8125rem;
  }

  /* Stack action buttons vertically on very small screens */
  .ktpa-notification-content {
    flex-direction: column;
    gap: 6px;
  }

  .ktpa-notification-action,
  .ktpa-notification-retry {
    width: 100%;
    text-align: center;
  }

  .ktpa-save-indicator {
    top: 50px;
    right: 8px;
    font-size: 0.6875rem;
    padding: 3px 8px;
  }
}

/* === DARK MODE SUPPORT === */

@media (prefers-color-scheme: dark) {
  .ktpa-notification {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  }

  .ktpa-notification-success {
    background: rgba(25, 135, 84, 0.2);
    border-color: rgba(25, 135, 84, 0.4);
    color: #A3CFBB;
  }

  .ktpa-notification-info {
    background: rgba(13, 110, 253, 0.2);
    border-color: rgba(13, 110, 253, 0.4);
    color: #9EC5FE;
  }

  .ktpa-notification-warning {
    background: rgba(255, 193, 7, 0.2);
    border-color: rgba(255, 193, 7, 0.4);
    color: #FFE69C;
  }

  .ktpa-notification-error {
    background: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.4);
    color: #F1AEB5;
  }

  .ktpa-save-indicator.saving {
    background: rgba(13, 110, 253, 0.2);
    color: #9EC5FE;
    border-color: rgba(13, 110, 253, 0.4);
  }

  .ktpa-save-indicator.saved {
    background: rgba(25, 135, 84, 0.2);
    color: #A3CFBB;
    border-color: rgba(25, 135, 84, 0.4);
  }
}

/* === REDUCED MOTION === */

@media (prefers-reduced-motion: reduce) {
  .ktpa-notification,
  .ktpa-notification-visible,
  .ktpa-notification-exit,
  .ktpa-save-indicator,
  .ktpa-notification-action,
  .ktpa-notification-retry,
  .ktpa-notification-dismiss {
    transition: none;
    animation: none;
  }

  .ktpa-notification-visible {
    opacity: 1;
    transform: none;
  }

  .ktpa-notification-exit {
    opacity: 0;
    transform: none;
  }

  .ktpa-save-indicator.saving::after {
    animation: none;
    opacity: 1;
  }
}

/* === PRINT STYLES === */

@media print {
  .ktpa-notification,
  .ktpa-save-indicator {
    display: none;
  }
}

/* === CONTAINER SPACING === */

/* Add margin to notification container if notifications stack */
.ktpa-notification + .ktpa-notification {
  margin-top: -8px;
}

/* === Z-INDEX MANAGEMENT === */

/* Ensure notifications appear above most content but below modals */
.ktpa-notification {
  z-index: 1000;
}

.ktpa-save-indicator {
  z-index: 9999;
}

/* If WordPress admin bar is present, adjust top position */
body.admin-bar .ktpa-save-indicator {
  top: 112px; /* 80px + 32px admin bar */
}

@media screen and (max-width: 782px) {
  body.admin-bar .ktpa-save-indicator {
    top: 106px; /* 60px + 46px admin bar on mobile */
  }
}

/* === NOTIFICATION INSERTION POINT === */

/* Ensure notifications appear at the top of the content area */
.ktpa-results-container > .ktpa-notification:first-child,
.ktpa-content > .ktpa-notification:first-child,
main > .ktpa-notification:first-child {
  margin-top: 0;
}

/* === UTILITY CLASSES === */

/* Manual dismiss button text (for tips) */
.ktpa-notification-dismiss[data-action="dismiss"]:not(:empty) {
  font-size: 0.875rem;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.ktpa-notification-dismiss[data-action="dismiss"]:not(:empty):hover {
  background: rgba(0, 0, 0, 0.2);
}

/* === TOAST NOTIFICATIONS === */
/* Compact, bottom-right, auto-dismiss notifications */

.ktpa-toast-container {
  position: fixed;
  bottom: 80px; /* Raised from 24px to avoid feedback button */
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  pointer-events: none;
}

.ktpa-toast {
  background: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  pointer-events: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.ktpa-toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.ktpa-toast-exit {
  opacity: 0;
  transform: translateY(20px);
}

.ktpa-toast-success {
  border-left: 4px solid #28a745;
  color: #155724;
}

.ktpa-toast-info {
  border-left: 4px solid #17a2b8;
  color: #0c5460;
}

.ktpa-toast-warning {
  border-left: 4px solid #ffc107;
  color: #856404;
}

.ktpa-toast-error {
  border-left: 4px solid #dc3545;
  color: #721c24;
}

.ktpa-toast:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.ktpa-toast-message {
  flex: 1;
  margin: 0;
}

.ktpa-toast-link {
  color: #007bff;
  text-decoration: none;
  font-weight: 500;
  margin-left: auto;
  white-space: nowrap;
  transition: color 0.2s;
}

.ktpa-toast-link:hover {
  color: #0056b3;
  text-decoration: underline;
}

/* Mobile responsiveness for toasts */
@media (max-width: 768px) {
  .ktpa-toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .ktpa-toast {
    font-size: 0.875rem;
  }
}

/* === SLIDE-IN PANEL === */
/* Right-edge slide-in panel, vertically centered, persistent until dismissed */

.ktpa-slide-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
}

.ktpa-slide-panel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  pointer-events: auto;
}

.ktpa-slide-panel-visible .ktpa-slide-panel-overlay {
  background: rgba(0, 0, 0, 0.3);
}

.ktpa-slide-panel-content {
  position: relative;
  background: #fff;
  width: 380px;
  max-width: 90vw;
  min-height: 200px;
  max-height: 80vh;
  padding: 28px 24px;
  border-radius: 12px 0 0 12px;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ktpa-slide-panel-visible .ktpa-slide-panel-content {
  transform: translateX(0);
}

.ktpa-slide-panel-exit .ktpa-slide-panel-content {
  transform: translateX(100%);
}

.ktpa-slide-panel-exit .ktpa-slide-panel-overlay {
  background: rgba(0, 0, 0, 0);
}

.ktpa-slide-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #666;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}

.ktpa-slide-panel-close:hover {
  background: #f0f0f0;
  color: #333;
}

.ktpa-slide-panel-close:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.ktpa-slide-panel-title {
  font-size: 1.375rem;
  font-weight: 600;
  color: #333;
  margin: 0;
  padding-right: 40px;
}

.ktpa-slide-panel-message {
  font-size: 1rem;
  line-height: 1.6;
  color: #555;
  margin: 0;
}

.ktpa-slide-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.ktpa-slide-panel-btn {
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
  font-family: inherit;
}

.ktpa-slide-panel-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.ktpa-slide-panel-btn:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.ktpa-slide-panel-btn-primary {
  background: var(--ktpa-primary, #f97316);
  color: #fff;
  border-color: var(--ktpa-primary, #f97316);
}

.ktpa-slide-panel-btn-primary:hover {
  background: #ea580c;
  border-color: #ea580c;
}

/* Mobile responsive - slide up from bottom */
@media (max-width: 480px) {
  .ktpa-slide-panel {
    align-items: flex-end;
    justify-content: center;
  }

  .ktpa-slide-panel-content {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    min-height: auto;
    max-height: 70vh;
    transform: translateY(100%);
  }

  .ktpa-slide-panel-visible .ktpa-slide-panel-content {
    transform: translateY(0);
  }

  .ktpa-slide-panel-exit .ktpa-slide-panel-content {
    transform: translateY(100%);
  }

  .ktpa-slide-panel-title {
    font-size: 1.25rem;
  }

  .ktpa-slide-panel-message {
    font-size: 0.9375rem;
  }

  .ktpa-slide-panel-btn {
    padding: 12px 16px;
    font-size: 0.875rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ktpa-slide-panel-overlay,
  .ktpa-slide-panel-content {
    transition: none;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .ktpa-slide-panel-content {
    background: #1a1a1a;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .ktpa-slide-panel-close {
    color: #aaa;
  }

  .ktpa-slide-panel-close:hover {
    background: #333;
    color: #fff;
  }

  .ktpa-slide-panel-title {
    color: #f0f0f0;
  }

  .ktpa-slide-panel-message {
    color: #ccc;
  }

  .ktpa-slide-panel-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #f0f0f0;
  }

  .ktpa-slide-panel-btn:hover {
    background: #333;
    border-color: #555;
  }
}
