/* Mailikan - Accessible Design */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:root {
  /* Signal.un.ms-inspired Color Palette */
  --primary-color: #3b536f; /* Blue-600 */
  --primary-hover: #406b9c; /* Blue-700 */
  --secondary-color: #64748B; /* Slate-500 */
  --accent-color: #059669; /* Emerald-600 */
  --danger-color: #DC2626; /* Red-600 */
  --warning-color: #D97706; /* Amber-600 */
  
  /* Neutral Colors */
  --text-primary: #0F172A; /* Slate-900 */
  --text-secondary: #1d1d1d; /* Slate-500 */
  --text-muted: #475569; /* Slate-600 - Improved contrast for accessibility */
  
  /* Background Colors - Neutral grays only */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC; /* Slate-50 */
  --bg-tertiary: #ffdba1; /* Slate-100 */
  --bg-card: #FFFFFF;
  --bg-column-1: #d6ccc2; /* Very light gray for first column */
  --bg-column-2: #f5ebe0; /* Slightly darker gray for second column */
  --bg-column-3: #e3d5ca; /* Darkest gray for third column */
  
  /* Shadows - More prominent shadows instead of borders */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", monospace;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem; /* Increased from 0.875rem for better accessibility - 16px base */
  line-height: 1.6; /* Improved line height for better readability */
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  min-height: 100vh;
}

/* Header */
header {
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--primary-color);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Email Stats */
.email-stats {
  display: flex;
  gap: var(--space-lg);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.stat-number {
  font-weight: 600;
  color: var(--text-primary);
}

/* Kanban Board */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
  padding: var(--space-xl);
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
}

/* Columns */
.column {
  background-color: #3b536f;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: fit-content;
  min-height: 600px;
}

.column-header {
  padding: var(--space-lg);
  background-color: rgb(6, 20, 39);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.column-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #ffdba1;
  letter-spacing: -0.025em;
}

.email-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 var(--space-xs);
  background-color: #ffffff;
  color: rgb(44, 44, 46);
  font-size: 0.8125rem; /* Increased from 0.75rem for better accessibility */
  font-weight: 600;
  border-radius: 9999px;
}

/* Email List */
.email-list {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 500px;
}

.email-list.drag-over {
  background: rgba(0, 122, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 122, 255, 0.2);
  transform: scaleY(1.02);
  transform-origin: top;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Email Cards */
.email-card {
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  cursor: grab;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 1;
}

.email-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.email-card.dragging {
  opacity: 0.8;
  transform: rotate(3deg) scale(1.02);
  cursor: grabbing;
  box-shadow: var(--shadow-xl);
}

.email-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xs);
}

.email-subject {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2; /* Standard property for compatibility */
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  margin-right: var(--space-sm);
}

/* Dropdown Styles */
.email-dropdown {
  position: relative;
  flex-shrink: 0;
  z-index: 10000;
}

.dropdown-btn {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropdown-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background-color 0.2s ease;
}

.dropdown-item:hover {
  background-color: var(--bg-secondary);
}

.dropdown-item:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.dropdown-item.archive {
  color: var(--danger-color);
  border-top: 1px solid var(--bg-tertiary);
}

.dropdown-item.archive:hover {
  background-color: var(--danger-color);
  color: white;
}

/* Email Actions */
.email-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--bg-tertiary);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 0.8rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
  background-color: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-sm);
}

.action-btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--primary-color);
}

.action-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.action-btn.archive {
  background-color: var(--danger-color);
  color: white;
}

.action-btn.archive:hover {
  background-color: #B91C1C; /* Darker red on hover */
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.email-from {
  font-size: 0.8125rem; /* Increased from 0.75rem for better accessibility */
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  font-weight: 500;
}

.email-date {
  font-size: 0.8125rem; /* Increased from 0.75rem for better accessibility */
  color: var(--text-muted);
  font-weight: 400;
}

.email-preview {
  font-size: 0.8125rem; /* Increased from 0.75rem for better accessibility */
  color: var(--text-secondary);
  margin-top: var(--space-sm);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2; /* Standard property for compatibility */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.loading-spinner {
  width: 0.5rem;
  height: 0.5rem;
  border: 2px solid var(--bg-tertiary);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
}

.modal-content {
  background-color: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-lg);
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.close:hover {
  color: var(--text-secondary);
  background-color: none;
}

.modal-body {
  padding: var(--space-lg);
  line-height: 1.6;
  color: var(--text-primary);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  min-height: 200px;
}

.empty-state-icon {
  width: 3rem;
  height: 3rem;
  background-color: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  font-size: 1.25rem;
  color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .kanban-board {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
  
  .column {
    min-height: 400px;
  }
  
  header {
    padding: var(--space-md) var(--space-lg);
  }
  
  header h1 {
    font-size: 1.25rem;
  }
}

@media (max-width: 640px) {
  .kanban-board {
    padding: var(--space-lg) var(--space-md);
  }
  
  header {
    flex-direction: column;
    gap: var(--space-md);
    align-items: stretch;
  }
  
  .header-actions {
    justify-content: space-between;
  }
  
  .email-stats {
    gap: var(--space-md);
  }
}

/* Focus Styles for Accessibility */
.email-card:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), var(--shadow-lg);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --text-muted: #000000;
    --shadow-sm: 0 2px 4px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 8px 0 rgb(0 0 0 / 0.2);
    --shadow-lg: 0 8px 16px 0 rgb(0 0 0 / 0.2);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Drag and Drop Styles */
.email-list.drag-over {
    background: rgba(235, 191, 71, 0.1);
    border-radius: 0px 0px var(--radius-lg) var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0, 122, 255, 0.2);
    transform: scaleY(1.02);
    transform-origin: top;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

.email-meta {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin: 1rem 0;
}

.email-meta p {
    margin-bottom: 0.5rem;
}

.email-content {
    margin-top: 1.5rem;
    line-height: 1.6;
}

/* Loading Spinner */
.loading {
    display: none;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    z-index: 999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .kanban-board {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1rem;
    }
}

/* Success/Error Messages */
.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    z-index: 1001;
    animation: slideInTop 0.4s ease;
    box-shadow: var(--shadow-lg);
}

.message.success {
    background-color: var(--accent-color); /* Green with better contrast */
}

.message.error {
    background-color: var(--danger-color); /* Red for errors */
}

@keyframes slideInTop {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}
