/**
 * PDF UI Components - Styling for UI Helpers
 * 
 * Provides styling for:
 * - Toast notifications (stacked)
 * - Modal dialogs
 * - Progress indicators (modern)
 * - Loading overlays
 * - Button spinners
 * 
 * Version: 1.0.0
 * Part of Tools Planet Static Site
 */

/* ==================== TOAST NOTIFICATIONS ==================== */

.toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  font-size: 15px;
  line-height: 1.4;
  opacity: 0;
  transform: translateX(400px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  pointer-events: auto;
  min-height: 56px;
}

.toast.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Toast types */
.toast-info {
  background: linear-gradient(135deg, rgba(23, 162, 184, 0.95) 0%, rgba(23, 162, 184, 0.85) 100%);
  color: white;
  border-left: 4px solid rgba(255, 255, 255, 0.5);
}

.toast-success {
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.95) 0%, rgba(40, 167, 69, 0.85) 100%);
  color: white;
  border-left: 4px solid rgba(255, 255, 255, 0.5);
}

.toast-error {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.95) 0%, rgba(220, 53, 69, 0.85) 100%);
  color: white;
  border-left: 4px solid rgba(255, 255, 255, 0.5);
}

.toast-warning {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.95) 0%, rgba(255, 193, 7, 0.85) 100%);
  color: #333;
  border-left: 4px solid rgba(0, 0, 0, 0.3);
}

.toast-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.toast-message {
  flex: 1;
  font-weight: 500;
}

.toast-action {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.35);
}

.toast-warning .toast-action {
  background: rgba(0, 0, 0, 0.15);
}

.toast-warning .toast-action:hover {
  background: rgba(0, 0, 0, 0.25);
}

.toast-close {
  padding: 4px;
  border: none;
  background: none;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.toast-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.toast-warning .toast-close:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* Responsive toasts */
@media (max-width: 768px) {
  .toast-container {
    bottom: 20px;
    right: 20px;
    left: 20px;
    max-width: none;
  }

  .toast {
    font-size: 14px;
    padding: 12px 16px;
  }
}

/* ==================== MODAL DIALOGS ==================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.visible {
  opacity: 1;
}

.modal-dialog {
  background: var(--entry, #1e1e1e);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-width: 500px;
  width: 100%;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 1px solid var(--border, #333);
}

.modal-dialog.visible {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border, #333);
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--primary, #fff);
}

.modal-body {
  padding: 24px;
}

.modal-message {
  margin: 0 0 16px;
  color: var(--secondary, #ccc);
  line-height: 1.6;
  font-size: 15px;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  background: var(--hljs-bg, #2d2d2d);
  color: var(--primary, #fff);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.modal-input:focus {
  outline: none;
  border-color: var(--theme, #1e90ff);
  box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-button {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-cancel {
  background: var(--hljs-bg, #2d2d2d);
  color: var(--secondary, #ccc);
  border: 1px solid var(--border, #333);
}

.modal-cancel:hover {
  background: var(--border, #333);
  color: var(--primary, #fff);
}

.modal-confirm,
.modal-ok {
  background: var(--theme, #1e90ff);
  color: white;
}

.modal-confirm:hover,
.modal-ok:hover {
  background: #1c7ed6;
  box-shadow: 0 4px 12px rgba(30, 144, 255, 0.3);
}

.modal-confirm.destructive {
  background: #dc3545;
}

.modal-confirm.destructive:hover {
  background: #c82333;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* Modal type indicators */
.modal-info .modal-title::before,
.modal-success .modal-title::before,
.modal-error .modal-title::before,
.modal-warning .modal-title::before {
  display: inline-block;
  margin-right: 10px;
  font-size: 24px;
}

.modal-info .modal-title::before {
  content: 'ℹ️';
}

.modal-success .modal-title::before {
  content: '✅';
}

.modal-error .modal-title::before {
  content: '❌';
}

.modal-warning .modal-title::before {
  content: '⚠️';
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal-dialog {
    max-width: none;
    margin: 0 10px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 16px;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-button {
    width: 100%;
  }
}

/* ==================== MODERN PROGRESS INDICATOR ==================== */

.progress-modern {
  padding: 20px 24px;
  border-radius: 12px;
  background: var(--entry, #1e1e1e);
  border: 1px solid var(--border, #333);
  margin: 20px 0;
}

.progress-modern.hidden {
  display: none;
}

.progress-message {
  color: var(--primary, #fff);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 12px;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--hljs-bg, #2d2d2d);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--theme, #1e90ff) 0%, #00d4ff 100%);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--secondary, #ccc);
}

.progress-percent {
  font-weight: 600;
  color: var(--theme, #1e90ff);
}

.progress-eta {
  font-style: italic;
}

.progress-modern.progress-success .progress-bar-fill {
  background: linear-gradient(90deg, #28a745 0%, #5cb85c 100%);
}

.progress-modern.progress-error .progress-bar-fill {
  background: linear-gradient(90deg, #dc3545 0%, #e74c3c 100%);
}

.progress-modern.progress-success .progress-message {
  color: #28a745;
}

.progress-modern.progress-error .progress-message {
  color: #dc3545;
}

/* ==================== LOADING OVERLAY ==================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.loading-overlay.visible {
  opacity: 1;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--theme, #1e90ff);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-message {
  color: white;
  font-size: 18px;
  font-weight: 500;
}

/* ==================== BUTTON SPINNER ==================== */

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-spinner {
  display: inline-block;
  margin-right: 8px;
  animation: spin 1s linear infinite;
  font-size: 16px;
}

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

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

.fade-out {
  animation: fadeOut 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ==================== DARK MODE ADJUSTMENTS ==================== */

@media (prefers-color-scheme: light) {
  .modal-dialog {
    background: #ffffff;
    border-color: #e0e0e0;
  }

  .modal-title {
    color: #222;
  }

  .modal-message {
    color: #555;
  }

  .modal-input {
    background: #f5f5f5;
    border-color: #ddd;
    color: #222;
  }

  .modal-cancel {
    background: #f5f5f5;
    color: #555;
    border-color: #ddd;
  }

  .progress-modern {
    background: #ffffff;
    border-color: #e0e0e0;
  }

  .progress-bar-container {
    background: #f5f5f5;
  }

  .progress-message {
    color: #222;
  }

  .progress-meta {
    color: #666;
  }
}

/* ========================================
   Download Modal Styles
   (Merged from tools-download.css)
   ======================================== */

/**
 * pdf-download-modal.css — Download Modal Styling
 * 
 * Modern download modal with glassmorphism design,
 * feedback icons, and full dark mode support.
 */

/* ========== Modal Overlay ========== */
.download-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

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

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

/* ========== Modal Container ========== */
.download-modal {
  background: linear-gradient(
    145deg,
    rgba(60, 60, 70, 0.95),
    rgba(40, 40, 50, 0.95)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: slideUp 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

[data-theme="light"] .download-modal {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.98),
    rgba(250, 250, 252, 0.98)
  );
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== Header ========== */
.download-modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.download-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.download-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0.5rem 0;
  color: var(--content);
}

.download-message {
  font-size: 0.95rem;
  color: var(--secondary);
  margin: 0;
  line-height: 1.5;
}

/* ========== Body ========== */
.download-modal-body {
  margin-bottom: 1.5rem;
}

/* ========== Download Buttons ========== */
.download-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
}

.download-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.download-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.download-btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.download-btn-primary:active:not(:disabled) {
  transform: translateY(0);
  animation: pulse 0.3s ease;
}

.download-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: linear-gradient(135deg, #888 0%, #666 100%);
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.98);
  }
}

.download-btn-icon {
  font-size: 1.25rem;
}

.download-btn-text {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-btn-size {
  font-size: 0.875rem;
  opacity: 0.8;
  font-weight: 400;
}

/* ========== File List (Multiple Downloads) ========== */
.download-files-list {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  max-height: 240px;
  overflow-y: auto;
}

[data-theme="light"] .download-files-list {
  background: rgba(0, 0, 0, 0.04);
}

/* Custom scrollbar */
.download-files-list::-webkit-scrollbar {
  width: 8px;
}

.download-files-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.download-files-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.download-files-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.download-file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.download-file-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.file-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.file-name {
  flex: 1;
  font-size: 0.9rem;
  color: var(--content);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.8rem;
  color: var(--secondary);
  flex-shrink: 0;
}

.download-btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-family: inherit;
}

.download-btn-small:hover:not(:disabled) {
  background: var(--hljs-bg);
  transform: scale(1.05);
}

.download-btn-small:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.download-btn-small.downloaded {
  background: #10b981;
}

/* ========== Footer & Feedback ========== */
.download-modal-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

[data-theme="light"] .download-modal-footer {
  border-top-color: rgba(0, 0, 0, 0.1);
}

.download-feedback {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 1rem;
}

.feedback-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  padding: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  font-family: inherit;
}

[data-theme="light"] .feedback-btn {
  border-color: rgba(0, 0, 0, 0.15);
}

.feedback-btn:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .feedback-btn:hover {
  border-color: rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.feedback-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.feedback-btn.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .feedback-btn.active {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.6);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

.feedback-icon {
  width: 28px;
  height: 28px;
  color: white;
  stroke-width: 2;
}

[data-theme="light"] .feedback-icon {
  color: var(--content);
}

.feedback-label {
  position: absolute;
  bottom: -24px;
  font-size: 0.75rem;
  color: var(--secondary);
  white-space: nowrap;
  font-weight: 500;
}

/* ========== Responsive Design ========== */
@media (max-width: 640px) {
  .download-modal {
    max-width: 95%;
    padding: 1.5rem;
  }

  .download-icon {
    font-size: 2.5rem;
  }

  .download-title {
    font-size: 1.25rem;
  }

  .download-message {
    font-size: 0.875rem;
  }

  .download-btn {
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
  }

  .download-btn-text {
    font-size: 0.875rem;
  }

  .download-btn-size {
    font-size: 0.75rem;
  }

  .download-files-list {
    max-height: 180px;
  }

  .feedback-btn {
    width: 56px;
    height: 56px;
  }

  .feedback-icon {
    width: 24px;
    height: 24px;
  }

  .feedback-label {
    font-size: 0.7rem;
    bottom: -22px;
  }
}

@media (max-width: 400px) {
  .download-modal {
    padding: 1.25rem;
  }

  .download-btn-text {
    max-width: 150px;
  }

  .file-name {
    max-width: 120px;
  }

  .feedback-btn {
    width: 52px;
    height: 52px;
  }

  .feedback-icon {
    width: 22px;
    height: 22px;
  }
}

/* ========== Print Styles ========== */
@media print {
  .download-modal-overlay {
    display: none !important;
  }
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  .download-modal-overlay,
  .download-modal,
  .download-icon,
  .download-btn,
  .feedback-btn {
    animation: none !important;
    transition: none !important;
  }
}


/* Web Share API Styles */
.download-btn-secondary {
  margin-top: 0.75rem;
  background: transparent !important;
  border: 2px solid var(--primary) !important;
  color: var(--primary) !important;
}

.download-btn-secondary:hover {
  background: var(--primary) !important;
  color: var(--theme) !important;
}

.download-btn-share {
  margin-left: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.download-btn-share:hover {
  background: var(--primary);
  color: var(--theme);
  border-color: var(--primary);
}

