/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #2d9d78 0%, #1a6b52 100%);
  min-height: 100vh;
  color: #333;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  color: white;
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info span {
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #2d9d78;
  color: white;
}

.btn-primary:hover {
  background: #248a65;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-large {
  padding: 15px 30px;
  font-size: 1.1rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

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

/* Tab Navigation */
.tab-navigation {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px;
  border-radius: 12px;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: white;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
  background: white;
  color: #2d9d78;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cards */
.card, .login-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.login-card {
  text-align: center;
  padding: 48px 24px;
}

.login-card h2 {
  margin-bottom: 12px;
  color: #333;
}

.login-card p {
  color: #666;
  margin-bottom: 24px;
}

.card h2 {
  margin-bottom: 20px;
  color: #333;
  font-size: 1.3rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2d9d78;
}

/* Check-in Header */
.checkin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.checkin-header h2 {
  margin-bottom: 0;
}

/* Date Picker */
.date-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-picker input[type="date"] {
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.date-picker input[type="date"]:focus {
  outline: none;
  border-color: #2d9d78;
}

.btn-date-nav {
  width: 36px;
  height: 36px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #555;
}

.btn-date-nav:hover {
  border-color: #2d9d78;
  color: #2d9d78;
}

/* Progress Bar */
.progress-section {
  margin-bottom: 20px;
}

.progress-bar {
  height: 12px;
  background: #e0f5ee;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2d9d78, #1a6b52);
  border-radius: 6px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  text-align: center;
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

/* Check-in List */
.checkin-list {
  margin-bottom: 20px;
}

.checkin-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.checkin-item:hover {
  border-color: #2d9d78;
  background: #f8fdfb;
}

.checkin-item.checked {
  border-color: #2d9d78;
  background: #e0f5ee;
}

.checkin-item.checked .checkin-checkbox {
  background: #2d9d78;
  border-color: #2d9d78;
}

.checkin-item.checked .checkin-checkbox::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin: 1px 0 0 3px;
}

.checkin-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 2px solid #ccc;
  border-radius: 6px;
  margin-right: 14px;
  transition: all 0.2s ease;
}

.checkin-emoji {
  font-size: 1.4rem;
  margin-right: 12px;
}

.checkin-name {
  font-size: 1rem;
  font-weight: 500;
  color: #333;
}

/* Emoji Picker */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.emoji-option {
  width: 44px;
  height: 44px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: white;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.emoji-option:hover {
  border-color: #2d9d78;
  transform: scale(1.1);
}

.emoji-option.selected {
  border-color: #2d9d78;
  background: #e0f5ee;
}

/* Habit List (Settings) */
.habit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  transition: border-color 0.2s ease;
}

.habit-item:hover {
  border-color: #2d9d78;
}

.habit-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.habit-item-emoji {
  font-size: 1.4rem;
}

.habit-item-name {
  font-weight: 500;
  color: #333;
}

.habit-item-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.btn-icon:hover {
  background: #f0f0f0;
  color: #333;
}

.btn-icon.deactivate:hover {
  background: #fff3e0;
  color: #e65100;
}

.btn-icon.reactivate:hover {
  background: #e0f5ee;
  color: #2d9d78;
}

/* Edit Habit Inline */
.habit-edit-form-block {
  width: 100%;
}

.emoji-picker-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.emoji-picker-inline .emoji-option {
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
}

.habit-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.habit-edit-row input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #2d9d78;
  border-radius: 8px;
  font-size: 0.95rem;
}

.habit-edit-row input:focus {
  outline: none;
}

.btn-save {
  padding: 6px 14px;
  background: #2d9d78;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-save:hover {
  background: #248a65;
}

.btn-cancel-edit {
  padding: 6px 14px;
  background: #f5f5f5;
  color: #666;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-cancel-edit:hover {
  background: #e0e0e0;
}

/* Data Management */
.data-mgmt-desc {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 20px;
}

.data-mgmt-group {
  margin-bottom: 16px;
}

.data-mgmt-group:last-child {
  margin-bottom: 0;
}

.data-mgmt-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 10px;
}

.data-mgmt-actions {
  display: flex;
  gap: 12px;
}

.btn-export,
.btn-import {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  background: white;
  color: #333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-export:hover {
  border-color: #2d9d78;
  color: #2d9d78;
}

.btn-import:hover {
  border-color: #e65100;
  color: #e65100;
}

/* Range Selector */
.range-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 6px;
  background: #f0f5f3;
  border-radius: 10px;
}

.range-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #666;
}

.range-btn:hover {
  background: rgba(45, 157, 120, 0.1);
  color: #2d9d78;
}

.range-btn.active {
  background: #2d9d78;
  color: white;
}

/* Chart Container */
.chart-container {
  height: 280px;
  margin-bottom: 10px;
}

/* Overall Stats */
.overall-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  text-align: center;
  padding: 16px;
  background: #f8fdfb;
  border-radius: 12px;
  border: 1px solid #e0f5ee;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: bold;
  color: #2d9d78;
  margin-bottom: 4px;
  word-break: break-all;
}

.stat-label {
  font-size: 0.8rem;
  color: #888;
}

/* Streak List */
.streak-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.streak-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.streak-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-item-emoji {
  font-size: 1.3rem;
}

.streak-item-name {
  font-weight: 500;
  color: #333;
}

.streak-stats {
  display: flex;
  gap: 16px;
}

.streak-stat {
  text-align: center;
  min-width: 60px;
}

.streak-stat-value {
  font-size: 1.3rem;
  font-weight: bold;
  color: #2d9d78;
}

.streak-stat-value.fire {
  color: #e65100;
}

.streak-stat-label {
  font-size: 0.7rem;
  color: #888;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Utility */
.hidden {
  display: none !important;
}

/* GitHub Icon */
.github-icon {
  width: 24px;
  height: 24px;
}

/* Responsive */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .card, .login-card {
    padding: 16px;
  }

  .checkin-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .date-picker {
    width: 100%;
  }

  .date-picker input[type="date"] {
    flex: 1;
  }

  .overall-stats {
    grid-template-columns: 1fr 1fr;
  }

  .streak-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .streak-stats {
    width: 100%;
    justify-content: space-around;
  }

  .chart-container {
    height: 220px;
  }

  .tab-btn {
    padding: 10px 8px;
    font-size: 0.85rem;
  }
}
