/* GridFlow - Base styles (shared across all pages) */

/* ===== Layout ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f5f5f5;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1em;
}

/* ===== Navbar ===== */
.navbar {
  background-color: #fff;
  border-bottom: 1px solid #e5e5e5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75em 1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.navbar-brand img {
  height: 32px;
}

.navbar-menu {
  display: flex;
  gap: 0.5em;
  align-items: center;
}

.navbar-link {
  padding: 0.5em 0.75em;
  text-decoration: none;
  color: #333;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.navbar-link:hover {
  background-color: #f0f0f0;
}

.navbar-link-danger {
  color: #d33;
}

.navbar-link-danger:hover {
  background-color: #fee;
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5em;
}

.navbar-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background-color: #333;
  margin: 4px 0;
}

@media (max-width: 768px) {
  .navbar-menu {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background-color: #fff;
    border-bottom: 1px solid #e5e5e5;
    flex-direction: column;
    padding: 0.5em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  .navbar-menu.active {
    display: flex;
  }

  .navbar-toggle {
    display: block;
  }

  .navbar-link {
    width: 100%;
    text-align: left;
  }
}

/* ===== Alerts / Flash Messages ===== */
.flash-container {
  position: fixed;
  top: 1em;
  right: 1em;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  max-width: 360px;
}

.alert {
  padding: 0.6em 1em;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.875em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: opacity 0.4s ease;
}

.alert svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

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

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

.alert-warning {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
}

.alert-info {
  background-color: #d1ecf1;
  border: 1px solid #bee5eb;
  color: #0c5460;
}

/* ===== JS Toasts (drag-and-drop errors, etc.) ===== */
.toast {
  position: fixed;
  top: 1em;
  right: 1em;
  z-index: 10000;
  padding: 0.6em 1em;
  border-radius: 6px;
  font-size: 0.875em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: opacity 0.4s ease;
  max-width: 360px;
}

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

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

/* ===== Cards ===== */
.card {
  background-color: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 3px;
  padding: 1.5em;
  margin-bottom: 1em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
  font-size: 1.25em;
  font-weight: 600;
  margin-bottom: 1em;
  padding-bottom: 0.75em;
  border-bottom: 1px solid #e5e5e5;
}

.card-body {
  margin: 1em 0;
}

.card-footer {
  margin-top: 1em;
  padding-top: 0.75em;
  border-top: 1px solid #e5e5e5;
}

/* ===== Modals ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

.modal.active,
.modal.modal-open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3em 1em;
}

dialog.modal {
  border: none;
  padding: 0;
  background: transparent;
}

dialog.modal[open] {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3em 1em;
}

dialog.modal.modal-open {
  background-color: rgba(0,0,0,0.5);
}

dialog.modal::backdrop {
  background-color: rgba(0,0,0,0.5);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.modal-backdrop button {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  cursor: default;
  font-size: 0;
  color: transparent;
}

.modal-content,
.modal-box {
  background-color: #fff;
  padding: 2em;
  border-radius: 6px;
  width: 90%;
  max-width: 600px;
  position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.modal-box.max-w-lg {
  max-width: 32rem;
}

.modal-box.max-w-2xl {
  max-width: 42rem;
}

.modal-action {
  display: flex;
  justify-content: flex-end;
  gap: 0.5em;
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px solid #e5e7eb;
}

.modal-close {
  position: absolute;
  right: 1em;
  top: 1em;
  font-size: 1.5em;
  font-weight: bold;
  color: #aaa;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
}

.modal-close:hover {
  color: #000;
}

/* ===== Priority Indicators ===== */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.priority-dot.low { background-color: #28a745; }
.priority-dot.medium { background-color: #ffc107; }
.priority-dot.high { background-color: #fd7e14; }
.priority-dot.critical { background-color: #dc3545; }

/* ===== Status Badges ===== */
.status-badge {
  display: inline-block;
  padding: 0.25em 0.5em;
  border-radius: 3px;
  font-size: 0.85em;
  font-weight: 500;
}

.status-todo { background-color: #e9ecef; color: #495057; }
.status-in-progress { background-color: #cfe2ff; color: #084298; }
.status-done { background-color: #d1e7dd; color: #0f5132; }

/* ===== Timer ===== */
@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.timer-active {
  animation: pulse-timer 2s ease-in-out infinite;
  color: #dc3545;
}

/* ===== Rich Text Content (rendered HTML from TipTap) ===== */
.comment-content ul,
.comment-content ol,
.description-content ul,
.description-content ol,
#desc-display ul,
#desc-display ol {
  padding-left: 1.5em;
  margin: 0.4em 0;
}

.comment-content ul,
.description-content ul,
#desc-display ul {
  list-style-type: disc;
}

.comment-content ol,
.description-content ol,
#desc-display ol {
  list-style-type: decimal;
}

.comment-content li,
.description-content li,
#desc-display li {
  margin: 0.2em 0;
}

/* ===== TipTap Editor ===== */
.editor-toolbar {
  display: flex;
  gap: 0.25em;
  padding: 0.5em;
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  flex-wrap: wrap;
}

.editor-btn {
  padding: 0.25em 0.5em;
  font-size: 0.85em;
  background-color: #fff;
  border: 1px solid #ccc;
}

.editor-btn:hover {
  background-color: #e9e9e9;
}

.toolbar-divider {
  color: #ccc;
  padding: 0 0.25em;
  line-height: 1.5;
}

.editor-content {
  min-height: 150px;
  padding: 1em;
  border: 1px solid #ccc;
  border-radius: 0 0 3px 3px;
  outline: none;
  background-color: #fff;
}

.editor-content:focus {
  border-color: #0078e7;
}

.ProseMirror {
  min-height: 150px;
  padding: 1em;
  outline: none;
}

.ProseMirror:focus {
  outline: none;
}

/* ===== Tables ===== */
.pure-table {
  width: 100%;
}

.pure-table th {
  background-color: #f0f0f0;
}

.pure-table-hover tbody tr:hover {
  background-color: #f9f9f9;
}

/* ===== Forms ===== */
.pure-form label {
  font-weight: 600;
  margin-bottom: 0.25em;
  display: inline-block;
}

.pure-form .required::after {
  content: " *";
  color: #dc3545;
}

.form-group {
  margin-bottom: 1em;
}

.form-help {
  font-size: 0.85em;
  color: #666;
  margin-top: 0.25em;
}

.form-error {
  font-size: 0.85em;
  color: #dc3545;
  margin-top: 0.25em;
}

/* ===== Buttons ===== */
.pure-button-primary {
  background-color: #0078e7;
  color: #fff;
}

.pure-button-primary:hover {
  background-color: #0060b6;
}

.pure-button-secondary {
  background-color: #6c757d;
  color: #fff;
}

.pure-button-secondary:hover {
  background-color: #545b62;
}

.pure-button-success {
  background-color: #28a745;
  color: #fff;
}

.pure-button-success:hover {
  background-color: #218838;
}

.pure-button-danger {
  background-color: #dc3545;
  color: #fff;
}

.pure-button-danger:hover {
  background-color: #c82333;
}

.pure-button-warning {
  background-color: #ffc107;
  color: #212529;
}

.pure-button-warning:hover {
  background-color: #e0a800;
}

.btn-outline {
  padding: 0.25em 0.6em;
  border-radius: 3px;
  font-size: 0.8em;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
}

.btn-outline-primary {
  border: 1px solid #0078e7;
  color: #0078e7;
}

.btn-outline-primary:hover {
  background-color: #0078e7;
  color: #fff;
}

.btn-outline-danger {
  border: 1px solid #dc3545;
  color: #dc3545;
}

.btn-outline-danger:hover {
  background-color: #dc3545;
  color: #fff;
}

/* ===== Filter Bar (shared) ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 1.5em;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input[type="text"] {
  padding: 0.5em 0.75em;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.9em;
}

.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
}

/* ===== Tenant Badge ===== */
.tenant-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 500;
  color: #fff;
}

/* ===== Utilities ===== */
.text-muted {
  color: #6c757d;
}

.text-danger {
  color: #dc3545;
}

.text-success {
  color: #28a745;
}

.text-warning {
  color: #ffc107;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 0.5em; }
.mt-2 { margin-top: 1em; }
.mt-3 { margin-top: 1.5em; }
.mb-1 { margin-bottom: 0.5em; }
.mb-2 { margin-bottom: 1em; }
.mb-3 { margin-bottom: 1.5em; }

.hidden {
  display: none;
}

/* ===== Loading Spinner ===== */
.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #0078e7;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 2em auto;
}

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

/* ===== Task Modal Overlay ===== */
.task-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 2em 1em;
}

.task-modal {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
  align-self: flex-start;
}

.task-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1.25em 1.5em;
}

.task-modal-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.task-modal-title-section {
  display: flex;
  align-items: center;
  gap: 0.75em;
  min-width: 0;
  flex: 1;
}

.task-id-badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.25em 0.6em;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}

.task-modal-title {
  color: #fff;
  font-size: 1.2em;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex-shrink: 0;
}

/* ===== Tag Input ===== */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  align-items: center;
}

.tag-inline-input {
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0.15em 0.4em;
  font-size: 0.8em;
  min-width: 80px;
  max-width: 140px;
  outline: none;
}

.tag-inline-input:focus {
  border-color: #667eea;
}

.tag-remove-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1.1em;
  line-height: 1;
  padding: 0 0.15em;
  margin-left: 0.1em;
}

.tag-remove-btn:hover {
  color: #dc3545;
}

/* ===== Comment Avatar ===== */
.comment-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  background-color: #667eea;
  color: #fff;
  font-size: 0.75em;
  font-weight: 600;
  flex-shrink: 0;
}

/* ===== Comment Card ===== */
.comment-card {
  padding: 0.75em;
  margin-bottom: 0.5em;
  border-radius: 6px;
  background-color: #f9f9fb;
  border: 1px solid #eee;
}

/* ===== Activity Timeline ===== */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
}

/* ===== Comment Editor Area ===== */
.comment-editor-area {
  background-color: #fff;
}

.btn-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.25em;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s;
}

.btn-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  text-decoration: none;
}

.task-modal-body {
  padding: 1.5em;
  max-height: 80vh;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.task-modal-body::-webkit-scrollbar {
  display: none;
}

/* ===== Task Modal Inline Metadata ===== */
.task-meta-section {
  margin-bottom: 1em;
  padding-bottom: 0.75em;
  border-bottom: 1px solid #e5e5e5;
}

.task-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6em 1.5em;
  font-size: 0.9em;
}

.task-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
}

.task-meta-cell.task-meta-full {
  grid-column: 1 / -1;
}

.task-meta-cell.task-meta-span2 {
  grid-column: span 2;
}

.task-meta-label {
  font-size: 0.75em;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.task-meta-select {
  padding: 0.3em 0.5em;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9em;
  background-color: #fff;
  cursor: pointer;
  width: 100%;
}

.task-meta-select:focus {
  border-color: #667eea;
  outline: none;
}

.timer-emoji-toggle {
  display: flex;
  align-items: center;
  gap: 0.15em;
  cursor: pointer;
  font-size: 0.85em;
  flex-shrink: 0;
}

.timer-emoji-toggle input[type="checkbox"] {
  display: none;
}

.timer-emoji-toggle span {
  opacity: 0.4;
  transition: opacity 0.15s;
  font-size: 1.1em;
  line-height: 1;
}

.timer-emoji-toggle input[type="checkbox"]:checked + span {
  opacity: 1;
}

.task-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-size: 0.8em;
  font-weight: 500;
  background-color: #e9ecef;
  color: #495057;
}

.task-meta-blocker {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-size: 0.8em;
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.task-meta-blocker-remove {
  background: none;
  border: none;
  color: #856404;
  cursor: pointer;
  font-size: 1.1em;
  line-height: 1;
  padding: 0 0.2em;
}

.task-meta-blocker-remove:hover {
  color: #dc3545;
}

/* ===== Task Timer + Inline Time Entry ===== */
.task-timer-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex-wrap: wrap;
  padding: 0.75em 1em;
  background-color: #f9f9f9;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  margin-bottom: 1em;
}

.task-time-divider {
  width: 1px;
  height: 24px;
  background-color: #ccc;
  margin: 0 0.25em;
}

.task-time-form {
  display: flex;
  align-items: center;
  gap: 0.4em;
  flex-wrap: wrap;
  flex: 1;
}

.task-time-input {
  padding: 0.35em 0.5em;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.85em;
}

.task-time-input:focus {
  border-color: #667eea;
  outline: none;
}

/* Responsive: mobile fullscreen */
@media (max-width: 640px) {
  .task-modal-overlay {
    padding: 0;
  }

  .task-modal {
    border-radius: 0;
    max-width: 100%;
    min-height: 100vh;
  }

  .task-modal-body {
    max-height: none;
  }

  .task-modal-header-content {
    flex-wrap: wrap;
  }

  .task-modal-title {
    font-size: 1em;
  }

  .task-timer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .task-time-divider {
    width: 100%;
    height: 1px;
    margin: 0.5em 0;
  }

  .task-time-form {
    flex-direction: column;
  }

  .task-time-input {
    width: 100% !important;
  }

  .task-meta-row {
    font-size: 0.85em;
  }
}
