/* =============================================
   CheckNest - Component Styles
   ============================================= */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn .material-icons-outlined {
  font-size: 18px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #0B8276;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-like {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-like.liked {
  background: #FDF2F8;
  color: var(--like);
  border-color: var(--like);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--surface);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--surface);
}

/* ── Checklist Card ── */
.checklist-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Home horizontal scroll */
.checklist-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
  cursor: grab;
}

.checklist-scroll::-webkit-scrollbar {
  display: none;
}

.checklist-scroll.dragging {
  cursor: grabbing;
  user-select: none;
}

.checklist-scroll .checklist-card {
  min-width: 260px;
  max-width: 280px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.checklist-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.checklist-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.checklist-card:active {
  transform: scale(0.98);
}

.card-category {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.card-category-icon {
  font-size: 16px;
  color: var(--primary);
}

.card-category-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  gap: 12px;
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-meta-item .material-icons-outlined {
  font-size: 14px;
}

/* ── Category Chips ── */
.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-scroll {
  cursor: grab;
}

.category-scroll.dragging {
  cursor: grabbing;
  user-select: none;
}

.category-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.2s;
}

.category-chip .material-icons-outlined {
  font-size: 16px;
}

.category-chip:hover,
.category-chip.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Generic Input ── */
.input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

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

/* ── Form Elements ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

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

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-check-group {
  padding: 8px 0;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
}

.alert-success {
  background: #F0FDF4;
  color: var(--success);
  border: 1px solid #BBF7D0;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
}

.badge-warning {
  background: #FEF3C7;
  color: #92400E;
}

/* ── Progress Bar ── */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-wrap.large {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 20px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-wrap.large .progress-bar {
  height: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.progress-bar-wrap.large .progress-text {
  font-size: 14px;
  text-align: center;
}

/* ── Modal ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  width: 100%;
  max-width: var(--max-width);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 0;
}

.pagination-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: all 0.2s;
}

.pagination-btn:hover {
  background: var(--surface);
}

.pagination-info {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
}

.empty-icon {
  font-size: 48px;
  color: var(--border);
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-sub {
  font-size: 14px !important;
}

.empty-state .btn {
  margin-top: 16px;
}

/* ── Sort Options ── */
.sort-options {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

.sort-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 16px;
  color: var(--text-secondary);
  background: var(--surface);
  transition: all 0.2s;
}

.sort-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ── Search Input ── */
.search-input-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 20px;
}

.search-input {
  width: 100%;
  padding: 12px 12px 12px 42px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg);
}

.search-form .category-scroll {
  margin-top: 12px;
}

@media (min-width: 768px) {
  .modal-content {
    border-radius: var(--radius);
    margin-bottom: 10vh;
  }

  .modal {
    align-items: center;
  }
}
