/* =============================================
   MyOrganizer — компоненти
   Картки, кнопки, форми, фільтри
   ============================================= */

/* =============================================
   Кнопки
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Основна кнопка */
.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* Прозора кнопка */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

/* Небезпечна кнопка */
.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

/* Кнопка Google */
.btn-google {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover {
  background: var(--color-bg-secondary);
  box-shadow: var(--shadow-md);
}

/* AI кнопка */
.btn-ai {
  padding: 5px 10px;
  font-size: 12px;
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--border-radius);
}
.btn-ai:hover:not(:disabled) {
  background: var(--color-primary-light);
}
.btn-ai:disabled {
  opacity: 0.5;
}

/* Повна ширина */
.btn-full {
  width: 100%;
}

/* Іконна кнопка */
.icon-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--border-radius);
  cursor: pointer;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

/* =============================================
   Поля введення
   ============================================= */
.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-text-muted);
}

.textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

/* =============================================
   Картки проектів
   ============================================= */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 480px) {
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .projects-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.project-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.project-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.project-card:hover::before {
  opacity: 1;
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.project-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  word-break: break-word;
  margin-right: 8px;
}

.project-card-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.project-card:hover .project-card-actions {
  opacity: 1;
}

.project-card-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
}

.project-card-count {
  background: var(--color-bg-secondary);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

/* =============================================
   Список записів
   ============================================= */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: 14px;
  transition: all var(--transition);
  position: relative;
  border-left: 3px solid transparent;
}

.entry-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}

/* Колір лівого бордеру по типу */
.entry-card[data-type="idea"] {
  border-left-color: var(--color-type-idea);
}
.entry-card[data-type="task"] {
  border-left-color: var(--color-type-task);
}
.entry-card[data-type="link"] {
  border-left-color: var(--color-type-link);
}

/* Завершена задача — приглушена */
.entry-card.completed {
  opacity: 0.6;
}
.entry-card.completed .entry-content {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.entry-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.entry-type-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.entry-type-badge.idea {
  background: rgba(139, 92, 246, 0.12);
  color: var(--color-type-idea);
}
.entry-type-badge.task {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-type-task);
}
.entry-type-badge.link {
  background: rgba(16, 185, 129, 0.12);
  color: var(--color-type-link);
}

.entry-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.entry-priority-dot.low { background: var(--color-priority-low); }
.entry-priority-dot.medium { background: var(--color-priority-medium); }
.entry-priority-dot.high { background: var(--color-priority-high); }

.entry-card-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.entry-card:hover .entry-card-actions {
  opacity: 1;
}

/* На мобільному завжди показуємо кнопки */
@media (max-width: 480px) {
  .entry-card-actions,
  .project-card-actions {
    opacity: 1;
  }
}

.entry-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  word-break: break-word;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-url {
  font-size: 12px;
  color: var(--color-type-link);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-url a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.entry-date {
  font-size: 11px;
  color: var(--color-text-muted);
}

.task-toggle-btn {
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  font-weight: 500;
}

.task-toggle-btn.active {
  border-color: var(--color-type-task);
  color: var(--color-type-task);
}

.task-toggle-btn.active:hover {
  background: rgba(59, 130, 246, 0.1);
}

.task-toggle-btn.completed {
  border-color: var(--color-success);
  color: var(--color-success);
}

.task-toggle-btn.completed:hover {
  background: var(--color-success-light);
}

/* =============================================
   Елементи бічної панелі
   ============================================= */
.sidebar-project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 14px;
  color: var(--color-text);
}

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

.sidebar-project-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar-project-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-project-item.active .sidebar-project-item-icon {
  background: var(--color-primary);
  color: white;
}

.sidebar-project-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-project-item-count {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* =============================================
   Результати пошуку
   ============================================= */
.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border-light);
}

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

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

.search-result-type {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-content {
  font-size: 14px;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.search-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* =============================================
   Модальне вікно для проекту (форма)
   ============================================= */
.project-form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.project-form-modal {
  background: var(--color-surface);
  border-radius: var(--border-radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.project-form-modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.project-form-modal .form-group {
  margin-bottom: 14px;
}

.project-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* =============================================
   Підказка про гарячі клавіші
   ============================================= */
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: var(--color-text-secondary);
}

/* =============================================
   Анімації
   ============================================= */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
  animation: fade-in 0.2s ease;
}

.animate-slide {
  animation: slide-up 0.25s ease;
}

/* Пульсація для AI обробки */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.processing {
  animation: pulse 1s ease infinite;
}

/* =============================================
   Мітка "виділений текст" у пошуку
   ============================================= */
mark {
  background: var(--color-warning-light);
  color: var(--color-text);
  border-radius: 2px;
  padding: 0 1px;
}
