/* web/css/style.css - Mobile First Design System */
:root {
  --bg: #0B0F19;
  --bg-card: #151C2C;
  --bg-card-hover: #1C2438;
  --bg-input: #0F1523;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --copper: #D97746;
  --copper-glow: rgba(217, 119, 70, 0.3);
  
  --alarm: #F43F5E;
  --alarm-bg: rgba(244, 63, 94, 0.12);
  
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.15);
  
  --text: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Base Mobile First */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* App Wrapper - Center on desktop, full width on mobile */
.app-container {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
  padding-bottom: 90px; /* Space for FAB */
}

@media (min-width: 540px) {
  body {
    background: radial-gradient(circle at 50% 0%, #151C2C 0%, #0B0F19 80%);
    padding: 20px 0;
  }
  .app-container {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
  }
}

/* Header Section */
.app-header {
  padding: 16px 18px 12px;
  background: linear-gradient(180deg, rgba(21, 28, 44, 0.95) 0%, rgba(11, 15, 25, 0.9) 100%);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.user-greeting {
  display: flex;
  flex-direction: column;
}

.greeting-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.greeting-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  cursor: pointer;
}

.sync-badge.connected {
  border-color: rgba(16, 185, 129, 0.3);
  color: #34D399;
}

.sync-badge.offline {
  border-color: rgba(245, 158, 11, 0.3);
  color: #FBBF24;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Week Navigator */
.week-navigator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.week-range-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-arrows {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-nav {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-nav:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-today {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary-hover);
  cursor: pointer;
  transition: var(--transition);
}

/* 7-Day Strip */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 2px 0 6px;
}

.day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 2px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  user-select: none;
}

.day-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.day-pill .day-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.day-pill .day-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.day-pill .day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  margin-top: 4px;
  opacity: 0;
  transition: var(--transition);
}

.day-pill.has-completed .day-dot {
  opacity: 1;
}

/* Active Day (Copper/Terracotta #D97746 like in the user's mockup) */
.day-pill.active {
  background: var(--copper);
  border-color: var(--copper);
  box-shadow: 0 4px 14px var(--copper-glow);
  transform: translateY(-1px);
}

.day-pill.active .day-label {
  color: rgba(255, 255, 255, 0.9);
}

.day-pill.active .day-num {
  color: #FFFFFF;
}

.day-pill.active .day-dot {
  background: #FFFFFF;
}

/* History Banner */
.history-banner {
  margin: 12px 18px 0;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(217, 119, 70, 0.12);
  border: 1px solid rgba(217, 119, 70, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #FFA270;
}

.btn-back-today {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--copper);
  color: white;
  border: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* Progress Bar */
.progress-section {
  padding: 14px 18px 6px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.progress-percent {
  color: var(--success);
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366F1, #10B981);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Tabs Filter */
.tabs-container {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.tab-btn.active {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Routines List */
.routines-list {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

/* Routine Card */
.routine-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition);
  position: relative;
}

.routine-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--bg-card-hover);
}

.routine-card.completed {
  opacity: 0.75;
  background: rgba(21, 28, 44, 0.6);
  border-color: rgba(16, 185, 129, 0.25);
}

.card-top-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* Checkbox Button */
.check-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 2px;
}

.check-btn:hover {
  border-color: var(--success);
}

.routine-card.completed .check-btn {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
}

/* Time Badge */
.time-badge {
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

/* Card Content: Title wrapping rule (2 lines max, 3rd line ellipsis) */
.card-content {
  flex: 1;
  min-width: 0;
}

.routine-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Quebra até 2 linhas; na 3ª coloca reticências */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.routine-card.completed .routine-title {
  text-decoration: line-through;
  color: var(--text-dim);
}

.routine-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card Bottom Details */
.card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 11px;
}

.card-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-tag {
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.badge-tag.alarm-on {
  background: var(--alarm-bg);
  color: var(--alarm);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.btn-card-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-card-action.btn-del:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--alarm);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 40px;
  opacity: 0.5;
}

/* Floating Action Button (+) */
.fab-btn {
  position: fixed;
  bottom: 24px;
  right: calc(50% - 240px); /* Center aligned on desktop */
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--copper) 0%, #E68A57 100%);
  border: none;
  color: #FFFFFF;
  box-shadow: 0 8px 24px var(--copper-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  transition: var(--transition);
  z-index: 50;
}

@media (max-width: 540px) {
  .fab-btn {
    right: 20px;
  }
}

.fab-btn:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 12px 28px var(--copper-glow);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end; /* Mobile: bottom sheet */
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@media (min-width: 540px) {
  .modal-overlay {
    align-items: center; /* Desktop: center modal */
  }
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 100%;
  max-width: 480px;
  background: #141B2B;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 20px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(40px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 540px) {
  .modal-box {
    border-radius: var(--radius-lg);
    transform: scale(0.95);
  }
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

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

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

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

/* Days Multi-selector in Modal */
.days-selector {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.day-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.day-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

/* Toggle Switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.12);
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--copper);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Action Buttons */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-md);
  background: var(--copper);
  border: none;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  box-shadow: 0 4px 14px var(--copper-glow);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-google {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  color: #111827;
  border: none;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 14px;
}

.btn-google:hover {
  background: #F3F4F6;
  transform: translateY(-1px);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1E293B;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-container.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-6px);
}
