/* ============================================
   UI/UX IMPROVEMENTS - November 10, 2025
   ============================================ */

/* ACCESSIBILITY: Visually Hidden Class */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to Main Content Link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: #6366f1;
  color: white;
  padding: 10px 20px;
  text-decoration: none;
  z-index: 100;
}

.skip-to-main:focus {
  top: 0;
}

/* PROBLEM 1: Inconsistent Button States */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
}

/* PROBLEM 2: Poor Touch Targets on Mobile */
@media (max-width: 768px) {
  .btn,
  .app-card,
  .filter-btn,
  button {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
  
  .app-card {
    padding: 20px 15px;
  }
  
  input,
  textarea,
  select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* PROBLEM 3: Modal Not Closing on Backdrop Click */
.modal {
  cursor: pointer;
}

.modal-card {
  cursor: default;
}

/* PROBLEM 4: Poor Contrast in Some Areas */
.app-desc {
  color: rgba(255, 255, 255, 0.75) !important; /* Was 0.6 - too low contrast */
}

.tagline {
  color: rgba(255, 255, 255, 0.8) !important; /* Was 0.6 */
}

.helper {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* PROBLEM 5: Workspace Header Wrapping on Tablet */
.workspace-header {
  flex-wrap: wrap;
  gap: 15px;
}

.workspace-header h2 {
  min-width: 200px;
}

/* PROBLEM 6: Input Focus Not Visible Enough */
input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(99, 102, 241, 0.5) !important;
  outline-offset: 2px;
  border-color: #6366f1 !important;
}

/* PROBLEM 7: Notification Overflow on Small Screens */
@media (max-width: 480px) {
  #notification-container {
    right: 10px;
    left: 10px;
    top: 10px;
  }
  
  .notification {
    min-width: auto;
    max-width: 100%;
  }
}

/* PROBLEM 8: App Grid Breaking on Tablet */
@media (min-width: 481px) and (max-width: 768px) {
  .app-grid-category {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 15px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .app-grid-category {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 18px;
  }
}

/* PROBLEM 9: Search Icon Not Aligned */
.search-wrapper {
  display: flex;
  align-items: center;
}

.search-icon {
  pointer-events: none;
}

/* PROBLEM 10: Category Filters Scrollbar Always Visible */
.category-filters {
  -webkit-overflow-scrolling: touch;
}

.category-filters::-webkit-scrollbar {
  height: 4px;
}

.category-filters::-webkit-scrollbar-track {
  background: transparent;
}

.category-filters::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

/* PROBLEM 11: Logo Text Breaking on Small Screens */
.logo-container {
  flex-wrap: nowrap;
}

@media (max-width: 380px) {
  .logo-text {
    font-size: 2em !important;
  }
  
  .logo-icon {
    font-size: 2em !important;
  }
}

/* PROBLEM 12: User Badge Overflow */
.user-badge {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

@media (max-width: 480px) {
  .user-badge {
    max-width: 150px;
  }
}

/* PROBLEM 13: Auth Actions Breaking on Small Screens */
@media (max-width: 380px) {
  .auth-actions {
    grid-template-columns: 1fr !important;
  }
}

/* PROBLEM 14: Workspace Content Scrolling Issues */
.workspace-content {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

/* PROBLEM 15: Better Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid rgba(99, 102, 241, 0.3);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* PROBLEM 16: Better Error States */
.error-state {
  padding: 20px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  text-align: center;
}

.error-state h3 {
  color: #ef4444;
  margin-bottom: 10px;
}

/* PROBLEM 17: Empty States */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
}

.empty-state-icon {
  font-size: 4em;
  opacity: 0.3;
  margin-bottom: 15px;
}

.empty-state h3 {
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.8);
}

/* PROBLEM 18: Modal Animation */
.modal:not(.hidden) {
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  animation: fadeOut 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.modal:not(.hidden) .modal-card {
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* PROBLEM 19: Better Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* PROBLEM 20: Smooth Page Transitions */
.page-transition {
  animation: pageIn 0.3s ease;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* PROBLEM 21: Better Tooltips */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* PROBLEM 22: Focus Trap for Modals */
.modal:not(.hidden) ~ * {
  filter: blur(2px);
  pointer-events: none;
}

/* PROBLEM 23: Better Scrollbar Styling */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) rgba(255, 255, 255, 0.05);
}

/* PROBLEM 24: High Contrast Mode Support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor !important;
  }
  
  .app-card {
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
  }
}

/* PROBLEM 25: Better Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .no-print,
  .btn,
  .filter-btn,
  .user-header,
  .modern-header {
    display: none !important;
  }
  
  .workspace {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: white !important;
  }
}

/* TYPOGRAPHY IMPROVEMENTS */
body {
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 700;
  margin-bottom: 0.5em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 1em;
}

/* CONSISTENT SPACING */
.spacing-xs { padding: 0.25rem; }
.spacing-sm { padding: 0.5rem; }
.spacing-md { padding: 1rem; }
.spacing-lg { padding: 1.5rem; }
.spacing-xl { padding: 2rem; }

.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }

/* IMPROVED CARD LAYOUTS */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* BETTER LIST STYLES */
.list-item {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* IMPROVED FORM ELEMENTS */
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* BADGE & TAG STYLES */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-info { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }

/* GRID UTILITIES */
.grid {
  display: grid;
  gap: 1rem;
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* FLEX UTILITIES */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* TEXT UTILITIES */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-light { font-weight: 300; }

/* ANIMATION UTILITIES */
.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-up {
  animation: slideUp 0.3s ease;
}

.scale-in {
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* IMPROVED SCROLLBAR FOR ALL ELEMENTS */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.5);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.7);
}
