/* ===== Routine View — Tinder-style ===== */
.view-routine {
  flex-direction: column;
  height: 100%;
}

.routine-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.routine-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.routine-view-title {
  font-size: 20px;
  font-weight: 700;
}

.routine-add-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 150ms;
}

.routine-add-btn:hover {
  opacity: 0.9;
  box-shadow: var(--shadow-md);
}

/* ===== Empty State ===== */
.routine-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.routine-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.routine-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.routine-empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Form ===== */
.routine-form {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.routine-form-section {
  margin-bottom: 16px;
}

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

.routine-form-input,
.routine-form-textarea,
.routine-form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
  box-sizing: border-box;
  transition: border-color 150ms;
}

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

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

/* Repeat group */
.routine-repeat-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.routine-repeat-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms;
}

.routine-repeat-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(79, 106, 255, 0.3);
}

.routine-day-select {
  width: auto;
  margin-top: 8px;
}

/* Time picker */
.routine-time-picker {
  display: flex;
  align-items: center;
  gap: 4px;
}

.routine-time-select {
  width: 70px;
}

.routine-time-sep {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Retry */
.routine-retry-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.routine-retry-select {
  width: auto;
}

.routine-retry-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Preview */
.routine-form-preview {
  font-size: 13px;
  color: var(--accent);
  padding: 8px 0;
  font-weight: 500;
}

/* Form actions */
.routine-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.routine-form-cancel,
.routine-form-submit {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  transition: all 150ms;
}

.routine-form-cancel {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.routine-form-cancel:hover {
  background: var(--bg-tertiary);
}

.routine-form-submit {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 106, 255, 0.3);
}

.routine-form-submit:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(79, 106, 255, 0.4);
}

/* ===== Skill Browser ===== */
.routine-skill-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-family);
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
}

.routine-skill-toggle:hover { text-decoration: underline; }

.routine-skill-browser {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.routine-skill-chip {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 150ms;
  text-align: left;
}

.routine-skill-chip:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.routine-skill-cmd {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.routine-skill-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.routine-skill-loading {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px;
}

/* ===== Routine Group ===== */
.routine-group {
  margin-bottom: 24px;
}

.routine-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.routine-group-icon {
  font-size: 16px;
}

.routine-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.routine-group-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== Routine Card ===== */
.routine-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: all 200ms ease;
}

.routine-card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.routine-card.routine-card-disabled {
  opacity: 0.5;
}

.routine-card-body {
  margin-bottom: 10px;
}

.routine-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.routine-card-info {
  flex: 1;
  min-width: 0;
}

.routine-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.routine-card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.routine-card-agent {
  font-weight: 600;
}

.routine-card-sep {
  color: var(--text-muted);
}

.routine-card-schedule {
  color: var(--text-secondary);
}

.routine-card-prompt {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

/* Last run status */
.routine-card-last-run {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.routine-card-last-run.success {
  border-left: 3px solid var(--status-online);
}

.routine-card-last-run.failed {
  border-left: 3px solid #EF4444;
}

.routine-last-status {
  font-weight: 700;
}

.routine-card-last-run.success .routine-last-status { color: var(--status-online); }
.routine-card-last-run.failed .routine-last-status { color: #EF4444; }

.routine-card-report {
  margin-left: auto;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms;
}

.routine-card-report:hover {
  background: var(--accent);
  color: white;
}

/* iOS-style Toggle Switch */
.routine-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.routine-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all 200ms;
}

.routine-switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: all 200ms;
}

.routine-switch input:checked + .routine-switch-slider {
  background: var(--status-online);
  border-color: var(--status-online);
}

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

/* Card actions */
.routine-card-actions {
  display: flex;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.routine-card-run,
.routine-card-edit,
.routine-card-delete {
  border: none;
  border-radius: var(--radius-full);
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms;
}

.routine-card-run {
  background: var(--accent-light);
  color: var(--accent);
}

.routine-card-run:hover {
  background: var(--accent);
  color: white;
}

.routine-card-run:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.routine-card-edit {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.routine-card-edit:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.routine-card-delete {
  background: var(--bg-secondary);
  color: var(--text-muted);
  margin-left: auto;
}

.routine-card-delete:hover {
  background: #FEF2F2;
  color: #EF4444;
}

/* ===== History ===== */
.routine-history-section {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.routine-history-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.routine-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light, var(--border));
}

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

.routine-history-dot.success { background: var(--status-online); }
.routine-history-dot.fail { background: #EF4444; }

.routine-history-name {
  font-weight: 500;
  flex-shrink: 0;
}

.routine-history-detail {
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routine-history-item.failed .routine-history-detail {
  color: #EF4444;
}

.routine-history-time {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.routine-history-report {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms;
  flex-shrink: 0;
}

.routine-history-report:hover {
  background: var(--accent);
  color: white;
}

/* ===== Report Modal ===== */
.routine-report-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

.routine-report-panel {
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
  animation: slideUp 250ms ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.routine-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.routine-report-title {
  font-size: 16px;
  font-weight: 600;
}

.routine-report-close {
  background: var(--bg-secondary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms;
}

.routine-report-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.routine-report-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.routine-report-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.routine-report-error {
  text-align: center;
  color: #EF4444;
  padding: 40px;
}

/* ===== Desktop: modal centered ===== */
@media (min-width: 768px) {
  .routine-report-modal {
    align-items: center;
  }

  .routine-report-panel {
    border-radius: var(--radius-xl);
    max-height: 70vh;
  }
}

/* ===== Mobile ===== */
@media (max-width: 767px) {
  .routine-scroll {
    padding: 16px;
  }

  .routine-repeat-group {
    gap: 4px;
  }

  .routine-repeat-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .routine-card {
    padding: 14px;
  }

  .routine-card-actions {
    flex-wrap: wrap;
  }

  .routine-history-item {
    flex-wrap: wrap;
    gap: 4px;
  }

  .routine-history-report {
    margin-left: auto;
  }
}
