/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Workflow Table Styles - Following Edward Tufte's Data Density Principles */

:root {
  /* Density Variables */
  --density-padding: 0.4rem;
  --density-font-size: 0.8rem;
  --density-line-height: 1.3;
  --density-row-height: 32px;
  --density-header-height: 40px;

  /* Status Colors - Semantic Color System */
  --status-green: #27ae60;
  --status-yellow: #f39c12;
  --status-blue: #3498db;
  --status-gray: #95a5a6;

  /* Interactive States */
  --hover-opacity: 0.05;
  --selected-opacity: 0.1;
  --active-border: 2px solid var(--status-blue);

  /* Layout Variables */
  --sidebar-width: 240px;
  --sidebar-collapsed: 48px;
  --top-bar-height: 48px;
  --breadcrumb-height: 36px;
  --toolbar-height: 40px;
}

/* Table Container */
.table-container {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: auto;
  max-height: calc(100vh - var(--top-bar-height) - var(--toolbar-height) - 3rem);
}

/* Dense Table Base Styles */
.dense-table {
  font-size: var(--density-font-size);
  line-height: var(--density-line-height);
  border-collapse: collapse;
  width: 100%;
  background: white;
}

.dense-table th {
  padding: var(--density-padding);
  height: var(--density-header-height);
  vertical-align: middle;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
}

.dense-table td {
  padding: var(--density-padding);
  height: var(--density-row-height);
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}

/* Allow variable height for template table rows */
.dense-table.template-table td {
  height: auto;
  min-height: var(--density-row-height);
  vertical-align: top;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.dense-table tr:hover {
  background-color: rgba(0, 0, 0, var(--hover-opacity));
}

.dense-table tr.selected {
  background-color: rgba(52, 152, 219, var(--selected-opacity));
}

/* Status Indicators */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.status-dot--active { 
  background-color: var(--status-green); 
}

.status-dot--attention { 
  background-color: var(--status-yellow); 
}

.status-dot--pending { 
  background-color: var(--status-blue); 
}

.status-dot--completed { 
  background-color: var(--status-gray); 
}

/* Column Specific Styles */
.column-checkbox {
  width: 32px;
  text-align: center;
}

.column-status {
  width: 24px;
  text-align: center;
}

.column-id {
  width: 60px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.75rem;
  color: #666;
}

.column-thumbnail {
  width: 60px;
  text-align: center;
}

.column-subject {
  width: auto;
  min-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-workflow {
  width: 150px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-state {
  width: 100px;
}

.column-assigned {
  width: 80px;
  text-align: center;
}

.column-started {
  width: 100px;
  font-size: 0.75rem;
  color: #666;
}

.column-actions {
  width: 80px;
  text-align: center;
}

/* Template Table Specific Column Styles */
.column-template {
  width: 200px;
  max-width: 200px;
  min-width: 150px;
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.4;
}

.column-description {
  width: 300px;
  max-width: 300px;
  min-width: 200px;
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.4;
}

.column-states {
  width: 80px;
  text-align: center;
  white-space: nowrap;
}

.column-transitions {
  width: 100px;
  text-align: center;
  white-space: nowrap;
}

.column-created {
  width: 120px;
  white-space: nowrap;
}

/* State Badges */
.state-badge {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.state-badge--draft {
  background-color: #e3f2fd;
  color: #1976d2;
}

.state-badge--review {
  background-color: #fff3e0;
  color: #f57c00;
}

.state-badge--pending {
  background-color: #e8f5e8;
  color: #388e3c;
}

.state-badge--completed {
  background-color: #f3e5f5;
  color: #7b1fa2;
}

/* Sortable Headers */
.sortable-header {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sortable-header:hover {
  background-color: rgba(0, 0, 0, var(--hover-opacity));
}

.sort-indicator {
  margin-left: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.6;
}

.sort-indicator.active {
  opacity: 1;
  color: var(--status-blue);
}

/* Action Buttons */
.action-button {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  margin: 0 0.1rem;
  font-size: 0.8rem;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.action-button:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, var(--hover-opacity));
}

/* Top Navigation */
.top-navigation {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-height);
  background: white;
  border-bottom: 1px solid #e0e0e0;
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 1rem;
}

.top-navigation__brand {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: #333;
  text-decoration: none;
}

.top-navigation__search {
  flex: 1;
  max-width: 400px;
  margin: 0 2rem;
}

.top-navigation__search input {
  width: 100%;
  padding: 0.4rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.8rem;
}

.top-navigation__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Sidebar */
.workflow-sidebar {
  position: fixed;
  left: 0;
  top: calc(var(--top-bar-height) + var(--breadcrumb-height));
  width: var(--sidebar-width);
  height: calc(100vh - var(--top-bar-height) - var(--breadcrumb-height));
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  padding: 0.5rem;
}

.workflow-sidebar.collapsed {
  width: var(--sidebar-collapsed);
  padding: 0.5rem;
}

.sidebar-section {
  margin-bottom: 1rem;
  overflow: hidden;
}

.sidebar-section__title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-filter {
  margin-bottom: 0.3rem;
}

.sidebar-filter label {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.15rem 0;
  width: 100%;
}

.sidebar-filter input[type="checkbox"] {
  margin-right: 0.5rem;
}

.sidebar-filter__count {
  margin-left: auto;
  font-size: 0.7rem;
  color: #666;
  background: #e0e0e0;
  padding: 0.1rem 0.3rem;
  border-radius: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: calc(var(--top-bar-height) + var(--breadcrumb-height));
  padding: 0.5rem;
  min-height: calc(100vh - var(--top-bar-height) - var(--breadcrumb-height));
  background: #f8f9fa;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

/* Toolbar */
.workflow-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-bottom: 1px solid #e0e0e0;
  background: white;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: relative;
  z-index: 10;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 300px;
}

.toolbar-search input {
  padding: 0.3rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.8rem;
  width: 200px;
}

.toolbar-info {
  font-size: 0.8rem;
  color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
  .workflow-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .workflow-sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .dense-table {
    font-size: 0.7rem;
  }
  
  .column-subject,
  .column-workflow {
    max-width: 120px;
  }
}

/* Utility Classes */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monospace {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.text-muted {
  color: #666;
}

.text-small {
  font-size: 0.75rem;
}

.flex-center {
  display: flex;
  align-items: center;
}

.gap-1 {
  gap: 0.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

/* Dropdown positioning and z-index */
[id$="-dropdown"] {
  z-index: 50;
}

/* Ensure dropdowns are properly positioned */
.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.hidden {
  display: none !important;
}

/* Modern Toast Notification System */
.toast-container {
  position: fixed;
  top: calc(var(--top-bar-height) + 1rem);
  right: 1rem;
  z-index: 2000;
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex !important;
  align-items: flex-start !important;
  gap: 0.75rem !important;
  padding: 1rem 1.25rem !important;
  margin-bottom: 0.75rem !important;
  background: white !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05) !important;
  border-left: 4px solid !important;
  pointer-events: auto !important;
  position: relative !important;
  overflow: hidden !important;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
  transform: translateX(0) !important;
  opacity: 1 !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  z-index: 2000 !important;
}

.toast::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

/* Toast Types */
.toast--success {
  border-left-color: #10b981 !important;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%) !important;
}

.toast--success .toast__icon {
  color: #10b981 !important;
}

.toast--error {
  border-left-color: #ef4444 !important;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
}

.toast--error .toast__icon {
  color: #ef4444 !important;
}

.toast--warning {
  border-left-color: #f59e0b !important;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%) !important;
}

.toast--warning .toast__icon {
  color: #f59e0b !important;
}

.toast--info {
  border-left-color: #3b82f6 !important;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
}

.toast--info .toast__icon {
  color: #3b82f6 !important;
}

/* Toast Content */
.toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 0.125rem;
}

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
}

.toast__message {
  font-size: 0.8rem;
  color: #4b5563;
  margin: 0;
  line-height: 1.4;
}

.toast__close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: #9ca3af;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-top: 0.125rem;
}

.toast__close:hover {
  color: #6b7280;
  background: rgba(0, 0, 0, 0.05);
}

.toast__close:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Progress Bar */
.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0 0 8px 8px;
  transition: width linear;
}

.toast--success .toast__progress {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.toast--error .toast__progress {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.toast--warning .toast__progress {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.toast--info .toast__progress {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

/* Animations */
@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast--exiting {
  animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Hover Effects */
.toast:hover {
  transform: translateX(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 8px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (max-width: 640px) {
  .toast-container {
    right: 0.5rem;
    left: 0.5rem;
    max-width: none;
  }
  
  .toast {
    padding: 0.875rem 1rem;
  }
  
  .toast__title {
    font-size: 0.8rem;
  }
  
  .toast__message {
    font-size: 0.75rem;
  }
}

/* Legacy Flash Message Support */
.flash-messages {
  position: fixed;
  top: calc(var(--top-bar-height) + 1rem);
  right: 1rem;
  z-index: 1000;
  max-width: 400px;
}

.flash-message {
  padding: 1rem 1.5rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease-out;
}

.flash-notice {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.flash-alert {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
