/**
 * Sprint 3 UX Enhancements CSS
 * Styles for confirmation dialogs, validation, shortcuts, auto-save, and filter presets
 */

/* ============================================
   Confirmation Dialogs
   ============================================ */

.confirm-dialog {
  max-width: 500px;
}

.confirm-dialog .modal-body {
  padding: 1.5rem;
}

.confirm-message {
  font-size: 1rem;
  line-height: 1.6;
  color: #2c3e50;
  margin-bottom: 0;
}

/* Dialog types */
.confirm-dialog-danger .modal-header {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
}

.confirm-dialog-danger .confirm-message {
  color: #c0392b;
}

.confirm-dialog-warning .modal-header {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: white;
}

.confirm-dialog-warning .confirm-message {
  color: #d68910;
}

.confirm-dialog-info .modal-header {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
}

/* ============================================
   Form Validation
   ============================================ */

.field-error {
  display: none;
  color: #e74c3c;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  animation: slideDown 0.2s ease;
}

.form-control.invalid,
input.invalid,
select.invalid,
textarea.invalid {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-control.invalid:focus,
input.invalid:focus,
select.invalid:focus,
textarea.invalid:focus {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

#form-error-summary {
  margin-bottom: 1.5rem;
  animation: slideDown 0.3s ease;
}

#form-error-summary ul {
  list-style: none;
}

#form-error-summary li {
  padding: 0.25rem 0;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Keyboard Shortcuts Help
   ============================================ */

.shortcuts-help {
  max-height: 500px;
  overflow-y: auto;
}

.shortcut-category {
  margin-bottom: 1.5rem;
}

.shortcut-category h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #ecf0f1;
}

.shortcuts-list {
  margin: 0;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f8f9fa;
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-item dt {
  font-family: 'Courier New', monospace;
  background: #ecf0f1;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #2c3e50;
  min-width: 80px;
  text-align: center;
}

.shortcut-item dd {
  margin: 0;
  flex: 1;
  padding-left: 1rem;
  color: #7f8c8d;
  font-size: 0.875rem;
}

/* ============================================
   Auto-Save Indicator
   ============================================ */

.autosave-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #7f8c8d;
  z-index: 1000;
  transition: all 0.3s ease;
  opacity: 0.7;
}

.autosave-indicator:hover {
  opacity: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.autosave-indicator svg {
  width: 14px;
  height: 14px;
  stroke: #95a5a6;
}

.autosave-indicator.saved {
  background: #d5f4e6;
  border-color: #27ae60;
  color: #27ae60;
}

.autosave-indicator.saved svg {
  stroke: #27ae60;
}

/* ============================================
   Mobile Responsive Enhancements
   ============================================ */

/* Mobile breakpoints */
@media (max-width: 768px) {
  /* Responsive container */
  .container { max-width: 100%; padding: 0.75rem; }
  
  /* Stack columns on mobile */
  .col-6, .col-4, .col-3 { grid-column: span 12; }
  
  /* Improve button touch targets */
  .btn, button { min-height: 44px; font-size: 1rem; }
  
  /* Mobile-friendly forms */
  .form-control, input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    min-height: 44px;
  }
  
  /* Stack form groups */
  .form-row { display: block; }
  .form-row .form-group { margin-bottom: 1rem; }
  
  /* Responsive modals */
  .modal-dialog {
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
  }
  
  .modal-content {
    border-radius: 0;
    height: 100%;
  }
  
  /* Autosave indicator mobile position */
  .autosave-indicator {
    bottom: 10px;
    right: 10px;
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }
  
  /* Hide desktop-only elements */
  .desktop-only { display: none !important; }
  
  /* Show mobile-only elements */
  .mobile-only { display: block !important; }
}

@media (max-width: 640px) {
  /* Extra small screens */
  .btn { padding: 0.625rem 1rem; }
  
  /* Reduce modal padding */
  .modal-body { padding: 1rem; }
  .modal-header { padding: 0.75rem 1rem; }
  .modal-footer { padding: 0.75rem 1rem; }
  
  /* Compact shortcuts help */
  .shortcut-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .shortcut-item dd { padding-left: 0; }
}

/* Tablet breakpoint */
@media (min-width: 768px) and (max-width: 1024px) {
  .container { max-width: 720px; }
  .col-6 { grid-column: span 6; }
  .col-4 { grid-column: span 6; }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  a, button, .btn, .clickable {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .btn:hover, button:hover { background: inherit; }
  
  /* Improve checkbox/radio touch targets */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }
}
  animation: checkmark 0.3s ease;
}

@keyframes checkmark {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Draft restore prompt */
.draft-restore-prompt {
  margin-bottom: 1.5rem;
  animation: slideDown 0.3s ease;
}

.draft-restore-prompt .btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

/* ============================================
   Filter Presets
   ============================================ */

.filter-presets {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.presets-header {
  margin-bottom: 0.75rem;
}

.presets-header label {
  font-weight: 600;
  color: #495057;
  margin: 0;
  font-size: 0.9rem;
}

.presets-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-btn {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.preset-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.preset-btn.active {
  background: #3498db;
  border-color: #3498db;
  color: white;
}

.preset-btn.active:hover {
  background: #2980b9;
  border-color: #2980b9;
}

/* ============================================
   Smooth Transitions & Animations
   ============================================ */

.modal-overlay {
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
}

.modal-dialog {
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform: scale(0.9);
  opacity: 0;
}

.modal-overlay.active .modal-dialog {
  transform: scale(1);
  opacity: 1;
}

/* ============================================
   Loading States & Skeleton Screens
   ============================================ */

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-card {
  height: 120px;
  margin-bottom: 1rem;
}

/* ============================================
   Empty States
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #95a5a6;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #7f8c8d;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  color: #95a5a6;
  margin-bottom: 1.5rem;
}

.empty-state .btn {
  margin-top: 1rem;
}

/* ============================================
   Button Loading States
   ============================================ */

.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 768px) {
  .autosave-indicator {
    bottom: 10px;
    right: 10px;
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }

  .filter-presets {
    padding: 0.75rem;
  }

  .presets-buttons {
    gap: 0.375rem;
  }

  .preset-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .shortcut-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .shortcut-item dd {
    padding-left: 0;
  }

  .confirm-dialog {
    max-width: 90%;
  }
}

/* ============================================
   Focus States for Accessibility
   ============================================ */

.btn:focus,
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
}

.btn-danger:focus {
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.25);
}

.btn-success:focus {
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.25);
}

/* ============================================
   Utility Classes
   ============================================ */

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.slide-in {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.bounce-in {
  animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   Sortable Table Headers
   ============================================ */

table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 28px;
  transition: background-color 0.2s ease;
}

table th.sortable:hover {
  background-color: rgba(52, 152, 219, 0.05);
}

table th.sortable::after {
  content: '↕️';
  position: absolute;
  right: 8px;
  font-size: 11px;
  opacity: 0.3;
  transition: opacity 0.2s ease;
}

table th.sortable:hover::after {
  opacity: 0.6;
}

table th.sortable.sort-asc::after {
  content: '▲';
  opacity: 1;
  color: #3498db;
}

table th.sortable.sort-desc::after {
  content: '▼';
  opacity: 1;
  color: #3498db;
}

/* ============================================
   V2.3.0: Return Metadata UI
   ============================================ */

/* Return info section in approval detail */
.return-info-section {
  margin: 16px 0;
  border: 2px solid #f39c12;
  border-radius: 8px;
  overflow: hidden;
  background: #fff9e6;
  animation: slideDown 0.3s ease;
}

.return-info-header {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.return-info-body {
  padding: 16px;
}

.return-info-body strong {
  color: #d68910;
}

.return-info-body ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.return-info-body li {
  padding: 4px 0;
  padding-left: 20px;
  position: relative;
}

.return-info-body li::before {
  content: '⚠️';
  position: absolute;
  left: 0;
}

/* Required change fields in edit form */
.form-control.required-change,
input.required-change,
select.required-change,
textarea.required-change {
  border: 2px solid #f39c12 !important;
  background: #fff3cd;
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
  animation: pulse 2s ease-in-out infinite;
}

.form-control.required-change:focus,
input.required-change:focus,
select.required-change:focus,
textarea.required-change:focus {
  border-color: #f39c12 !important;
  box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.2);
}

/* Required field badge */
.required-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #f39c12;
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  animation: bounceIn 0.5s ease;
}

/* Pulse animation for required fields */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(243, 156, 18, 0.2);
  }
}

/* Locked approval warning */
.locked-approval-warning {
  padding: 16px;
  background: #ffe5e5;
  border: 2px solid #e74c3c;
  border-radius: 8px;
  margin: 16px 0;
  animation: slideDown 0.3s ease;
}

.locked-approval-warning strong {
  color: #c0392b;
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}

.locked-approval-warning p {
  margin: 0;
  color: #e74c3c;
  font-size: 13px;
}

/* Dark mode support for return metadata */
body.dark-mode .return-info-section {
  background: #3a2f1f;
  border-color: #d68910;
}

body.dark-mode .return-info-body {
  color: #f8f9fa;
}

body.dark-mode .form-control.required-change,
body.dark-mode input.required-change,
body.dark-mode select.required-change,
body.dark-mode textarea.required-change {
  background: #3a2f1f;
  color: #f8f9fa;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .return-info-section {
    margin: 12px -8px;
  }
  
  .return-info-header {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .return-info-body {
    padding: 12px;
    font-size: 12px;
  }
  
  .required-badge {
    font-size: 10px;
    padding: 1px 6px;
  }
}
