/* Matti Hub - Estilos Globais e Responsivos */
:root {
  --bg-primary: #0f1117;
  --bg-secondary: #171923;
  --bg-card: #1f2330;
  --bg-card-hover: #262b3b;
  --bg-input: #12141c;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: rgba(99, 102, 241, 0.5);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  --accent-lista: #06b6d4;
  --accent-treino: #10b981;
  --accent-trips: #f59e0b;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Container do App */
.app-container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-primary);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

/* Header */
.app-header {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: 16px;
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(99, 102, 241, 0.5));
}

/* Força a cor do SVG se renderizado em container ou invertido */
.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.header-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Views */
.view-section {
  display: none;
  flex: 1;
  padding: 24px 20px;
  animation: fadeIn 0.25s ease-out forwards;
}

.view-section.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Home / Hub */
.hub-greeting {
  margin-bottom: 28px;
}

.hub-greeting h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.hub-greeting p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Hub Grid de Ícones / Cards */
.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 480px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
}

.hub-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
}

.hub-card:not(.disabled):hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-md);
}

.hub-card:not(.disabled):active {
  transform: scale(0.985);
}

.hub-card-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 18px;
  flex-shrink: 0;
  transition: var(--transition);
}

.hub-card-icon svg {
  width: 28px;
  height: 28px;
}

/* Cores específicas de ícone */
.icon-lista {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-lista);
  border: 1px solid rgba(6, 182, 212, 0.25);
}
.hub-card:hover .icon-lista {
  background: rgba(6, 182, 212, 0.22);
}

.icon-treino {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-treino);
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.hub-card:hover .icon-treino {
  background: rgba(16, 185, 129, 0.22);
}

.icon-trips {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-trips);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.hub-card-content {
  flex: 1;
}

.hub-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hub-card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.hub-card-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.badge-disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-subtle);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hub-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.hub-card.disabled:active {
  transform: none;
}

.hub-card-arrow {
  color: var(--text-subtle);
  margin-left: 12px;
  transition: transform 0.2s ease;
}

.hub-card:not(.disabled):hover .hub-card-arrow {
  transform: translateX(3px);
  color: var(--text-main);
}

/* Tela de To-Do (Lista / Treino) */
.view-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-back:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-back svg {
  width: 18px;
  height: 18px;
}

.view-header {
  margin-bottom: 22px;
}

.view-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.view-title-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-title-icon svg {
  width: 22px;
  height: 22px;
}

.view-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Progresso */
.progress-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.progress-bar-bg {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Formulário de Adicionar */
.add-form {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.input-text {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  color: var(--text-main);
  font-size: 0.98rem;
  outline: none;
  transition: var(--transition);
}

.input-text:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-text::placeholder {
  color: var(--text-subtle);
}

.btn-add {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 18px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-add:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-add:active {
  transform: translateY(0);
}

/* Filtros e Ações */
.list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn.active {
  background: var(--bg-card-hover);
  color: #fff;
}

.btn-clear-completed {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-clear-completed:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

/* Lista de Tarefas */
.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Trava seleção de texto global durante o arrasto */
body.is-dragging-active {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

.todo-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.todo-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.todo-item.completed {
  background: rgba(23, 25, 35, 0.6);
  border-color: rgba(255, 255, 255, 0.04);
}

/* Drag Handle */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: grab;
  touch-action: none; /* Essencial para sensibilidade mobile imediata sem scroll */
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  padding: 0;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.drag-handle svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.drag-handle:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.drag-handle:active {
  cursor: grabbing;
  color: var(--primary-light);
}

/* Item em estado de arrasto */
.todo-item.is-dragging {
  opacity: 0.95;
  background: #232738 !important;
  border-color: var(--primary-light) !important;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(99, 102, 241, 0.5) !important;
  transform: scale(1.02);
  z-index: 100 !important;
  transition: none !important;
}

.todo-list.is-sorting .todo-item:not(.is-dragging) {
  transition: transform 0.15s ease;
}

/* Checkbox Customizado */
.todo-checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--text-subtle);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  position: relative;
}

.todo-checkbox-label:hover {
  border-color: var(--primary-light);
}

.todo-item.completed .todo-checkbox-label {
  background: var(--accent-treino);
  border-color: var(--accent-treino);
}

.todo-checkbox-label svg {
  width: 14px;
  height: 14px;
  color: #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: var(--transition);
}

.todo-item.completed .todo-checkbox-label svg {
  opacity: 1;
  transform: scale(1);
}

.todo-text {
  flex: 1;
  font-size: 0.98rem;
  color: var(--text-main);
  word-break: break-word;
  transition: var(--transition);
}

.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.todo-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.todo-action-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.65;
  transition: var(--transition);
}

.todo-action-btn:hover {
  opacity: 1;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.todo-action-btn.star-btn {
  color: var(--text-subtle);
}

.todo-action-btn.star-btn:hover {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.todo-item.is-starred .star-btn {
  color: #f59e0b;
  opacity: 1;
}

.todo-item.is-starred .star-btn svg {
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.5));
}

.todo-action-btn.edit-btn:hover {
  color: var(--primary-light);
  background: rgba(99, 102, 241, 0.12);
}

.todo-action-btn.delete-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.todo-action-btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Card Destacado (Starred) */
.todo-item.is-starred {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, #1f2330 100%);
  border-color: rgba(245, 158, 11, 0.38);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.08), inset 3px 0 0 #f59e0b;
}

.todo-item.is-starred:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, #262b3b 100%);
  border-color: rgba(245, 158, 11, 0.52);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.12), inset 3px 0 0 #f59e0b;
}

.todo-item.completed.is-starred {
  background: rgba(23, 25, 35, 0.75);
  border-color: rgba(245, 158, 11, 0.2);
  box-shadow: inset 3px 0 0 rgba(245, 158, 11, 0.45);
}

@keyframes starPop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.35) rotate(15deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.star-pop svg {
  animation: starPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Modo de Edição Inline */
.todo-edit-wrap {
  display: none;
  flex: 1;
  align-items: center;
  gap: 8px;
}

.todo-item.is-editing .todo-checkbox-label,
.todo-item.is-editing .todo-text,
.todo-item.is-editing .todo-actions,
.todo-item.is-editing .drag-handle {
  display: none !important;
}

.todo-item.is-editing .todo-edit-wrap {
  display: flex;
}

.todo-edit-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.todo-edit-btn-save {
  background: var(--primary);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.todo-edit-btn-save:hover {
  background: var(--primary-light);
}

.todo-edit-btn-save svg {
  width: 17px;
  height: 17px;
}

.todo-edit-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.todo-edit-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-main);
}

.todo-edit-btn-cancel svg {
  width: 17px;
  height: 17px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  color: var(--text-subtle);
  opacity: 0.5;
}

.empty-state-text {
  font-size: 0.95rem;
}

/* Toast de Notificação */
.toast-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: rgba(30, 35, 48, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease-out;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer sutil */
.app-footer {
  margin-top: auto;
  padding-top: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  padding-left: 20px;
  padding-right: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-subtle);
  border-top: 1px solid var(--border-color);
}

/* Mobile specific tweaks */
@media (max-width: 640px) {
  .app-container {
    box-shadow: none;
  }
  .app-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: 14px;
    padding-left: calc(18px + env(safe-area-inset-left, 0px));
    padding-right: calc(18px + env(safe-area-inset-right, 0px));
  }
  .view-section {
    padding: 18px 16px;
  }
  .hub-card {
    padding: 16px 18px;
  }
}
