/* EventFlow - Main Stylesheet
 * Blueprint Noir Design System
 *
 * Import order matters:
 * 1. Variables (design tokens)
 * 2. Reset (normalize browser defaults)
 * 3. Base elements (buttons, forms)
 * 4. Pages
 */

/* Base */
@import url('./base/variables.css');
@import url('./base/reset.css');
@import url('./base/elements.css');
@import url('./base/buttons.css');
@import url('./base/forms.css');

/* Pages */
@import url('./pages/home.css');
@import url('./pages/canvas.css');
@import url('./pages/catalogue.css');
@import url('./pages/keybindings.css');
@import url('./pages/login.css');
@import url('./pages/share.css');
@import url('./pages/shared.css');
@import url('./pages/settings.css');

/* Components */
@import url('./components/modal.css');
@import url('./components/discussion.css');
@import url('./components/activity-panel.css');
@import url('./components/panel-view.css');
@import url('./components/color-picker.css');

/* App Shell */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas-bg);
}

.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding-top: var(--toolbar-height);
}

/* Canvas Wrapper */
.canvas-wrapper {
  flex: 1;
  position: relative;
  margin-left: var(--tool-panel-width);
  margin-right: var(--properties-panel-width);
  margin-bottom: var(--slice-bar-height);
  overflow: hidden;
}

/* Responsive Layout */
@media (max-width: 1024px) {
  .canvas-wrapper {
    margin-right: 0;
  }

  .properties-panel {
    transform: translateX(100%);
    transition: transform var(--duration-normal) var(--ease-default);
  }

  .properties-panel.open {
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  .canvas-wrapper {
    margin-left: 0;
  }

  .tool-panel {
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-default);
  }

  .tool-panel.open {
    transform: translateX(0);
  }

  /* Mobile toolbar adjustments */
  .toolbar-title {
    display: none;
  }

  .toolbar-center {
    justify-content: flex-start;
  }
}

/* Utility Classes */
.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;
}

.no-scroll {
  overflow: hidden;
}

/* Focus management */
:focus-visible {
  outline: 2px solid var(--selection);
  outline-offset: 2px;
}

/* Selection highlight */
::selection {
  background: var(--selection);
  color: var(--text-primary);
}

/* Loading States */
.loading {
  position: relative;
  pointer-events: none;

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--depth-1);
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--depth-2) 25%,
    var(--depth-3) 50%,
    var(--depth-2) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;

  .empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    opacity: 0.5;
  }

  .empty-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
  }

  .empty-description {
    font-size: var(--text-sm);
    color: var(--text-muted);
    max-width: 300px;
  }
}

/* Drag & Drop States */
.drop-target {
  position: relative;

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px dashed var(--color-command);
    border-radius: var(--radius-lg);
    background: var(--color-command-glow);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast) var(--ease-default);
  }

  &.drag-over::before {
    opacity: 1;
  }
}

/* Keyboard shortcuts hint */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--depth-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--border-default);
}

/* ==========================================================================
 * Toast Notifications
 * ========================================================================== */
.toast-container {
  position: fixed;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--depth-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  overflow: hidden;
  animation: toastSlideIn 0.3s var(--ease-out) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.exiting {
  animation: toastSlideOut 0.2s var(--ease-default) forwards;
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateY(-100%);
  }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--space-1);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
}

.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-default);
}

.toast-close:hover {
  color: var(--text-primary);
}

/* Progress bar for auto-dismiss */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--selection);
  transform-origin: left;
  animation: toastProgress linear forwards;
}

@keyframes toastProgress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Toast variants */
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--color-command); }

/* Toast action button (for navigating to errors etc) */
.toast-action {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border: none;
  background: var(--text-primary);
  color: var(--depth-1);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);

  &:hover {
    opacity: 0.9;
  }
}

/* Toast dismiss button */
.toast-dismiss {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-default);

  &:hover {
    color: var(--text-primary);
  }

  svg {
    width: 100%;
    height: 100%;
  }
}

/* Colored toast variants with left border */
.toast-info {
  border-left: 4px solid var(--blue-6);

  .toast-icon { color: var(--blue-6); }
}

.toast-success {
  border-left: 4px solid var(--green-6);

  .toast-icon { color: var(--green-6); }
}

.toast-warning {
  border-left: 4px solid var(--orange-6);

  .toast-icon { color: var(--orange-6); }
}

.toast-error {
  border-left: 4px solid var(--red-6);

  .toast-icon { color: var(--red-6); }
}

/* =============================================================================
   Notification System
   ============================================================================= */

.notification-bell {
  position: relative;
  background: transparent;
  border: none;
  padding: var(--size-2);
  cursor: pointer;
  color: var(--gray-7);
  transition: color 0.15s ease;

  &:hover {
    color: var(--gray-9);
  }

  .notification-bell-icon {
    width: var(--size-5);
    height: var(--size-5);
  }
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: var(--size-4);
  height: var(--size-4);
  padding: 0 var(--size-1);
  background: var(--red-6);
  color: white;
  font-size: var(--font-size-0);
  font-weight: var(--font-weight-6);
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
}

.notifications-panel {
  position: absolute;
  top: 100%;
  right: 0;
  width: min(360px, 90vw);
  max-height: 400px;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-4);
  overflow: hidden;
  z-index: 1000;
}

.notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--size-3);
  border-bottom: 1px solid var(--surface-3);

  h3 {
    margin: 0;
    font-size: var(--font-size-2);
    font-weight: var(--font-weight-6);
    color: var(--text-1);
  }

  .notifications-mark-all {
    background: transparent;
    border: none;
    color: var(--blue-6);
    font-size: var(--font-size-0);
    cursor: pointer;
    padding: var(--size-1) var(--size-2);
    border-radius: var(--radius-1);

    &:hover {
      background: var(--surface-2);
    }
  }
}

.notifications-list {
  max-height: 350px;
  overflow-y: auto;
}

.notifications-empty {
  padding: var(--size-6);
  text-align: center;
  color: var(--text-2);

  p {
    margin: 0;
  }
}

.notification-row {
  display: flex;
  gap: var(--size-3);
  padding: var(--size-3);
  border-bottom: 1px solid var(--surface-2);
  transition: background 0.15s ease;

  &:hover {
    background: var(--surface-2);
  }

  &:last-child {
    border-bottom: none;
  }

  &.unread {
    background: var(--blue-1);

    &:hover {
      background: var(--blue-2);
    }
  }
}

.notification-icon {
  flex-shrink: 0;
  width: var(--size-5);
  height: var(--size-5);
  color: var(--text-2);

  svg {
    width: 100%;
    height: 100%;
  }
}

.notification-content {
  flex: 1;
  min-width: 0;

  .notification-message {
    margin: 0 0 var(--size-1) 0;
    font-size: var(--font-size-1);
    color: var(--text-1);
    line-height: 1.4;

    strong {
      font-weight: var(--font-weight-6);
    }
  }

  .notification-time {
    font-size: var(--font-size-0);
    color: var(--text-2);
  }
}

.notification-actions {
  display: flex;
  gap: var(--size-1);
  flex-shrink: 0;

  button, a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--size-5);
    height: var(--size-5);
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    border-radius: var(--radius-1);
    padding: 0;
    text-decoration: none;

    &:hover {
      background: var(--surface-3);
      color: var(--text-1);
    }

    svg {
      width: var(--size-3);
      height: var(--size-3);
    }
  }
}

/* =============================================================================
   Actions Panel
   ============================================================================= */

.actions-panel {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-2);
  overflow: hidden;
}

.actions-header {
  display: flex;
  align-items: center;
  padding: var(--size-3);
  border-bottom: 1px solid var(--surface-3);
  background: var(--surface-2);

  h3 {
    margin: 0;
    font-size: var(--font-size-1);
    font-weight: var(--font-weight-6);
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: var(--size-2);
  }

  .actions-icon {
    width: var(--size-4);
    height: var(--size-4);
    color: var(--text-2);
  }

  .actions-count {
    font-weight: var(--font-weight-4);
    color: var(--text-2);
    font-size: var(--font-size-0);
  }
}

.actions-list {
  max-height: 300px;
  overflow-y: auto;
}

.actions-empty {
  padding: var(--size-4);
  text-align: center;
  color: var(--text-2);

  p {
    margin: 0 0 var(--size-1) 0;
  }

  .actions-hint {
    font-size: var(--font-size-0);

    code {
      background: var(--surface-2);
      padding: 0 var(--size-1);
      border-radius: var(--radius-1);
      font-size: var(--font-size-0);
    }
  }
}

.action-row {
  display: flex;
  gap: var(--size-2);
  padding: var(--size-3);
  border-bottom: 1px solid var(--surface-2);
  transition: background 0.15s ease;

  &:hover {
    background: var(--surface-2);
  }

  &:last-child {
    border-bottom: none;
  }

  &.completed {
    opacity: 0.6;

    .action-description {
      text-decoration: line-through;
    }
  }
}

.action-status-icon {
  flex-shrink: 0;
  width: var(--size-4);
  height: var(--size-4);

  svg {
    width: 100%;
    height: 100%;
  }

  .open-icon {
    color: var(--text-2);
  }

  .progress-icon {
    color: var(--blue-6);
  }

  .completed-icon {
    color: var(--green-6);
  }
}

.action-content {
  flex: 1;
  min-width: 0;

  .action-type-badge {
    margin-bottom: var(--size-1);

    .badge {
      display: inline-block;
      padding: 0 var(--size-1);
      font-size: var(--font-size-00);
      font-weight: var(--font-weight-6);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      border-radius: var(--radius-1);

      &.action {
        background: var(--blue-2);
        color: var(--blue-8);
      }

      &.decision {
        background: var(--violet-2);
        color: var(--violet-8);
      }

      &.question {
        background: var(--orange-2);
        color: var(--orange-8);
      }
    }
  }

  .action-description {
    margin: 0 0 var(--size-1) 0;
    font-size: var(--font-size-1);
    color: var(--text-1);
    line-height: 1.4;
  }

  .action-answer {
    margin: var(--size-1) 0;
    padding: var(--size-2);
    background: var(--green-1);
    border-radius: var(--radius-1);
    font-size: var(--font-size-0);
    color: var(--text-1);

    strong {
      font-weight: var(--font-weight-6);
    }
  }

  .action-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--size-2);
    font-size: var(--font-size-0);
    color: var(--text-2);

    .action-assignee {
      color: var(--blue-6);
      font-weight: var(--font-weight-5);
    }
  }
}

.action-actions {
  display: flex;
  gap: var(--size-1);
  flex-shrink: 0;

  .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--size-6);
    height: var(--size-6);
    background: transparent;
    border: 1px solid var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    border-radius: var(--radius-1);
    transition: all 0.15s ease;

    &:hover {
      background: var(--surface-3);
      color: var(--text-1);
    }

    &.complete:hover {
      background: var(--green-2);
      border-color: var(--green-6);
      color: var(--green-8);
    }

    &.answer:hover {
      background: var(--blue-2);
      border-color: var(--blue-6);
      color: var(--blue-8);
    }

    svg {
      width: var(--size-3);
      height: var(--size-3);
    }
  }
}

.actions-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--size-4);
  height: var(--size-4);
  padding: 0 var(--size-1);
  background: var(--blue-6);
  color: white;
  font-size: var(--font-size-0);
  font-weight: var(--font-weight-6);
  border-radius: var(--radius-round);
}

/* Print styles */
@media print {
  .toolbar,
  .tool-panel,
  .properties-panel,
  .slice-bar,
  .toast-container,
  .modal-backdrop,
  .modal {
    display: none !important;
  }

  .canvas-wrapper {
    margin: 0;
  }

  .diagram-canvas {
    width: 100%;
    height: auto;
  }
}
