/**
 * TASKMATE - Modal Styles
 * =======================
 * Modals, Lightbox, Onboarding - Modernes Light Theme
 */

/* ========================================
   MODAL OVERLAY
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-overlay);
  opacity: 0;
  transition: opacity var(--transition-default);
}

.modal-overlay.visible {
  opacity: 1;
}

/* ========================================
   MODAL
   ======================================== */

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: calc(100% - 32px);
  max-width: 500px;
  max-height: calc(100vh - 64px);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: all var(--transition-default);
}

.modal.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-small {
  max-width: 400px;
}

.modal-large {
  max-width: 800px;
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-5) var(--spacing-6);
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 20px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* Save Status Indicator (Auto-Save) */
.save-status-indicator {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--spacing-1) var(--spacing-3);
  border-radius: var(--radius-lg);
  margin-left: auto;
  margin-right: var(--spacing-3);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.save-status-indicator.saving {
  opacity: 1;
  color: var(--warning);
}

.save-status-indicator.saved {
  opacity: 1;
  color: var(--success);
  animation: fadeOut 2s ease-in-out forwards;
}

.save-status-indicator.error {
  opacity: 1;
  color: var(--error);
}

@keyframes fadeOut {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* Modal Body */
.modal-body {
  flex: 1;
  padding: var(--spacing-6);
  overflow-y: auto;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-4) var(--spacing-6);
  border-top: 1px solid var(--border-light);
  gap: var(--spacing-4);
}

.modal-footer-left,
.modal-footer-right {
  display: flex;
  gap: var(--spacing-2);
}

/* ========================================
   TASK MODAL SPECIFIC
   ======================================== */

/* Time Estimate Inputs */
.time-estimate-inputs {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

.time-estimate-inputs input {
  width: 70px;
  text-align: center;
}

/* Labels Select */
.labels-select {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
}

.label-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.label-checkbox:hover {
  background: var(--bg-tertiary);
}

.label-checkbox input {
  display: none;
}

.label-checkbox .checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.label-checkbox input:checked + .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.label-checkbox input:checked + .checkmark::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: solid var(--text-inverse);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.label-color-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
}

.btn-add-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
  padding: var(--spacing-2) var(--spacing-3);
  color: var(--text-tertiary);
  background: none;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.btn-add-label:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Subtasks */
.subtask-progress {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  margin-bottom: var(--spacing-3);
}

.subtask-progress .progress {
  flex: 1;
}

.subtask-progress span {
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.subtasks-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin-bottom: var(--spacing-3);
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.subtask-item.dragging {
  opacity: 0.5;
  background: var(--bg-secondary);
}

.subtask-item.drag-over-top {
  border-top-color: var(--primary);
}

.subtask-item.drag-over-bottom {
  border-bottom-color: var(--primary);
}

/* Drag Handle */
.subtask-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: var(--text-xs);
  padding: 2px 4px;
  user-select: none;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.subtask-item:hover .subtask-drag-handle {
  opacity: 1;
}

.subtask-drag-handle:active {
  cursor: grabbing;
}

.subtask-item input[type="checkbox"] {
  flex-shrink: 0;
}

.subtask-item input[type="text"] {
  flex: 1;
  padding: var(--spacing-1) var(--spacing-2);
  font-size: var(--text-sm);
  background: transparent;
  border: none;
}

.subtask-item input[type="text"]:focus {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.subtask-item.completed .subtask-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Subtask Actions */
.subtask-actions {
  display: flex;
  gap: var(--spacing-1);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.subtask-item:hover .subtask-actions {
  opacity: 1;
}

.subtask-edit,
.subtask-delete {
  padding: 4px 6px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.subtask-edit:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.subtask-delete:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* Edit Input */
.subtask-edit-input {
  flex: 1;
  padding: var(--spacing-1) var(--spacing-2);
  font-size: var(--text-sm);
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  outline: none;
}

/* Add Subtask Form */
.add-subtask-form {
  display: flex;
  gap: var(--spacing-2);
}

.add-subtask-form input {
  flex: 1;
}

.subtask-title {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: text;
}

/* Links */
.links-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin-bottom: var(--spacing-3);
}

.link-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding: var(--spacing-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.link-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.link-info {
  flex: 1;
  overflow: hidden;
}

.link-title {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.link-url {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-actions {
  display: flex;
  gap: var(--spacing-1);
}

.add-link-form {
  display: flex;
  gap: var(--spacing-2);
}

.add-link-form input {
  flex: 1;
}

/* Attachments */
.attachments-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--spacing-3);
  margin-bottom: var(--spacing-3);
}

.attachment-item {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.attachment-preview {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
}

.attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-preview .icon {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}

.attachment-info {
  padding: var(--spacing-3);
}

.attachment-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.attachment-actions {
  position: absolute;
  top: var(--spacing-2);
  right: var(--spacing-2);
  display: flex;
  gap: var(--spacing-1);
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.attachment-actions .btn {
  background: rgba(0, 0, 0, 0.6) !important;
  border: none !important;
  border-radius: var(--radius-md) !important;
  padding: 6px 8px !important;
  cursor: pointer;
  color: white !important;
  transition: all var(--transition-fast);
  font-size: 14px;
  font-weight: bold;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-actions .btn:hover {
  background: rgba(0, 0, 0, 0.85) !important;
  transform: scale(1.1);
}

.attachment-actions .btn:last-child:hover {
  background: var(--error) !important;
}

/* File Upload */
.file-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: var(--spacing-8);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  text-align: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.file-upload-area:hover,
.file-upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-area .icon {
  width: 32px;
  height: 32px;
}

.file-input-label {
  color: var(--primary);
  cursor: pointer;
  font-weight: var(--font-medium);
}

.file-input-label:hover {
  text-decoration: underline;
}

.file-hint {
  font-size: var(--text-xs);
}

/* Comments */
.comments-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: var(--spacing-4);
}

.comment-item {
  display: flex;
  gap: var(--spacing-3);
}

.comment-avatar {
  flex-shrink: 0;
}

.comment-content {
  flex: 1;
  background: var(--bg-tertiary);
  padding: var(--spacing-3) var(--spacing-4);
  border-radius: var(--radius-xl);
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-1);
}

.comment-author {
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.comment-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.comment-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.comment-text p {
  margin-bottom: var(--spacing-1);
}

.comment-text p:last-child {
  margin-bottom: 0;
}

.add-comment-form {
  display: flex;
  gap: var(--spacing-3);
  align-items: flex-end;
}

.add-comment-form textarea {
  flex: 1;
}

/* History */
.history-container {
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-3);
  padding: var(--spacing-3) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-light);
}

.history-item:last-child {
  border-bottom: none;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--primary);
}

.history-text {
  flex: 1;
  color: var(--text-secondary);
}

.history-text strong {
  color: var(--text-primary);
}

.history-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Color Presets */
.color-presets {
  display: flex;
  gap: var(--spacing-2);
  margin-bottom: var(--spacing-3);
}

.color-preset {
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.color-preset:hover,
.color-preset.selected {
  border-color: var(--text-primary);
  transform: scale(1.1);
}

/* ========================================
   CONFIRM MODAL
   ======================================== */

#confirm-message {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* ========================================
   SHORTCUTS MODAL
   ======================================== */

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-3);
}

.shortcut {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  padding: var(--spacing-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.shortcut kbd {
  min-width: 28px;
  text-align: center;
}

.shortcut span {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ========================================
   LIGHTBOX
   ======================================== */

.lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.95);
  z-index: calc(var(--z-modal) + 100);
}

.lightbox-close {
  position: absolute;
  top: var(--spacing-6);
  top: calc(var(--spacing-6) + env(safe-area-inset-top, 0px));
  right: var(--spacing-6);
  right: calc(var(--spacing-6) + env(safe-area-inset-right, 0px));
  width: 48px;
  height: 48px;
  font-size: 32px;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

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

#lightbox-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: var(--radius-lg);
}

/* ========================================
   ONBOARDING TOUR
   ======================================== */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: calc(var(--z-modal) + 50);
}

.onboarding-tooltip {
  position: absolute;
  width: 340px;
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-modal) + 51);
}

.onboarding-content {
  padding: var(--spacing-6);
}

.onboarding-content h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--spacing-2);
}

.onboarding-content p {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.onboarding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-4) var(--spacing-6);
  border-top: 1px solid var(--border-light);
}

#onboarding-step {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ========================================
   SETTINGS - COLOR PICKER
   ======================================== */

.settings-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--spacing-6) 0;
}

.color-picker-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
}

.color-option {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.color-option:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-option.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-primary);
}

.color-option.selected::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.color-custom-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.color-custom-row input[type="color"] {
  width: 40px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
}

.color-custom-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-custom-row input[type="color"]::-webkit-color-swatch {
  border-radius: var(--radius-sm);
  border: none;
}

.color-current-display {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-default);
  flex-shrink: 0;
}

.color-hex-display {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 70px;
}

.color-preview-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

#user-color-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  color: white;
  font-size: var(--text-base);
}

/* ========================================
   ARCHIVE MODAL
   ======================================== */

.archive-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  max-height: 60vh;
  overflow-y: auto;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-4);
  padding: var(--spacing-4);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast);
}

.archive-item:hover {
  background: var(--bg-hover);
}

.archive-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: var(--spacing-2);
  margin: calc(-1 * var(--spacing-2));
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
}

.archive-item-info:hover {
  background: var(--bg-hover);
}

.archive-item-title {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--spacing-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-item-info:hover .archive-item-title {
  color: var(--primary);
}

.archive-item-meta {
  display: flex;
  gap: var(--spacing-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.archive-item-meta span {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
}

.archive-item-actions {
  display: flex;
  gap: var(--spacing-2);
  flex-shrink: 0;
}

.archive-empty {
  text-align: center;
  padding: var(--spacing-8);
  color: var(--text-muted);
}

.priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.priority-badge.high {
  background: rgba(239, 68, 68, 0.1);
  color: #DC2626;
}

.priority-badge.medium {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

.priority-badge.low {
  background: rgba(34, 197, 94, 0.1);
  color: #16A34A;
}
