/* =====================================================
   PHASE 7: Mission Control + Reminders + Calendar Sync
   Wren — Your always-on secretary
   ===================================================== */

/* =====================================================
   MISSION CONTROL SIDEBAR
   ===================================================== */

.mission-control-sidebar {
  position: fixed;
  top: 0;
  right: -380px;
  width: 360px;
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -6px 0 30px rgba(0, 0, 0, 0.12);
  z-index: 900;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.mission-control-sidebar.is-open {
  right: 0;
}

/* Header */
.mc-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-secondary);
  flex-shrink: 0;
}

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

.mc-header-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.2px;
}

.mc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.mc-close-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-hover);
}

/* Date bar */
.mc-date-bar {
  padding: 7px 18px;
  background: var(--color-primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* Body */
.mc-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mc-body::-webkit-scrollbar {
  width: 4px;
}
.mc-body::-webkit-scrollbar-track {
  background: transparent;
}
.mc-body::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

/* Sections */
.mc-section {
  border-bottom: 1px solid var(--color-border);
}

.mc-section-header {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: var(--color-bg-secondary);
  transition: background 0.15s;
}

.mc-section-header:hover {
  background: var(--color-hover, rgba(0,0,0,0.04));
}

.mc-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.mc-section-badge {
  background: var(--color-primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

.mc-section-badge.badge-zero {
  background: var(--color-border);
  color: var(--color-text-secondary);
}

.mc-section-badge.badge-warning {
  background: #f59e0b;
}

.mc-section-badge.badge-success {
  background: #10b981;
}

.mc-section-badge.badge-danger {
  background: #ef4444;
}

.mc-section-chevron {
  font-size: 10px;
  color: var(--color-text-secondary);
  transition: transform 0.2s ease;
}

.mc-section.collapsed .mc-section-chevron {
  transform: rotate(-90deg);
}

.mc-section-body {
  padding: 10px 18px 12px;
}

.mc-section.collapsed .mc-section-body {
  display: none;
}

/* MC Items */
.mc-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.mc-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.mc-item:hover {
  opacity: 0.75;
}

.mc-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 5px;
  flex-shrink: 0;
}

.mc-item-dot.dot-warning { background: #f59e0b; }
.mc-item-dot.dot-success { background: #10b981; }
.mc-item-dot.dot-danger  { background: #ef4444; }
.mc-item-dot.dot-muted   { background: var(--color-text-secondary); }

.mc-item-content {
  flex: 1;
  min-width: 0;
}

.mc-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-bottom: 2px;
}

.mc-item-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

.mc-empty {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-style: italic;
  padding: 6px 0;
  text-align: center;
}

/* Activity feed */
.mc-activity-item {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

.mc-activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.mc-activity-time {
  font-size: 10px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  padding-top: 1px;
  width: 32px;
  flex-shrink: 0;
  font-weight: 600;
}

.mc-activity-text {
  font-size: 12px;
  color: var(--color-text-primary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reminder items inside MC */
.mc-reminder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

.mc-reminder-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.mc-reminder-time {
  font-size: 10px;
  color: #f59e0b;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.mc-reminder-text {
  flex: 1;
  font-size: 12px;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-reminder-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.mc-reminder-item:hover .mc-reminder-delete {
  opacity: 1;
}

.mc-reminder-delete:hover {
  color: #ef4444;
}

/* MC Toggle tab */
.mc-toggle-btn {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px 0 0 8px;
  padding: 14px 7px;
  cursor: pointer;
  z-index: 899;
  line-height: 1;
  box-shadow: -3px 0 14px rgba(0, 0, 0, 0.15);
  transition: background 0.2s, right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mc-toggle-btn:hover {
  background: var(--color-primary-hover, #4338ca);
}

.mc-toggle-btn.sidebar-open {
  right: 360px;
}

.mc-toggle-icon {
  font-size: 16px;
}

.mc-toggle-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  writing-mode: vertical-rl;
}

/* Overlay */
.mc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  z-index: 898;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mc-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* =====================================================
   REMINDERS
   ===================================================== */

/* Reminder button in toolbar */
.reminder-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}

.reminder-toolbar-btn:hover {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}

.reminder-toolbar-btn.has-reminder {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}

/* Reminder Modal */
.reminder-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.reminder-modal {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 26px;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
}

.reminder-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reminder-note-chip {
  font-size: 12px;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 7px 11px;
  margin-bottom: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-field {
  margin-bottom: 15px;
}

.reminder-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.reminder-field input[type="datetime-local"],
.reminder-field input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.reminder-field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.reminder-quick-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.reminder-quick-btn {
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}

.reminder-quick-btn:hover,
.reminder-quick-btn.active {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}

.reminder-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.reminder-save-btn {
  flex: 1;
  padding: 10px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

.reminder-save-btn:hover {
  background: var(--color-primary-hover, #4338ca);
}

.reminder-cancel-btn {
  padding: 10px 18px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}

.reminder-cancel-btn:hover {
  border-color: var(--color-text-primary);
  color: var(--color-text-primary);
}

/* Reminder fired toast */
.reminder-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: #f59e0b;
  color: white;
  padding: 13px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.35);
  z-index: 1200;
  max-width: 300px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  animation: wrenToastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wrenToastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.reminder-toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.reminder-toast-body {
  flex: 1;
}

.reminder-toast-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.reminder-toast-msg {
  font-size: 13px;
  opacity: 0.95;
  line-height: 1.35;
}

.reminder-toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

.reminder-toast-close:hover {
  color: white;
}

/* Success toast (shared) */
.wren-success-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  color: white;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 1200;
  animation: wrenToastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* =====================================================
   CALENDAR SYNC MODAL
   ===================================================== */

.cal-sync-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cal-sync-content {
  background: var(--color-surface);
  border-radius: 16px;
  width: 500px;
  max-width: 100%;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
}

.cal-sync-content::-webkit-scrollbar {
  width: 4px;
}
.cal-sync-content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.cal-sync-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
  flex-shrink: 0;
}

.cal-sync-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.cal-sync-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.cal-sync-close:hover {
  color: var(--color-text-primary);
  background: var(--color-hover);
}

.cal-sync-body {
  padding: 20px 22px 24px;
  flex: 1;
}

.cal-sync-section {
  margin-bottom: 26px;
}

.cal-sync-section:last-child {
  margin-bottom: 0;
}

.cal-sync-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

/* Option cards */
.cal-option-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cal-option-card:hover {
  border-color: rgba(79, 70, 229, 0.4);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.06);
}

.cal-option-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.cal-option-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

.cal-option-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.cal-option-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin-bottom: 12px;
}

.cal-option-desc a {
  color: var(--color-primary);
  text-decoration: none;
}

.cal-option-desc a:hover {
  text-decoration: underline;
}

.cal-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}

.cal-btn-primary {
  background: var(--color-primary);
  color: white;
}

.cal-btn-primary:hover {
  background: var(--color-primary-hover, #4338ca);
}

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

.cal-btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.cal-btn-google {
  background: white;
  color: #3c4043;
  border: 1px solid #dadce0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cal-btn-google:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  background: #f8f9fa;
}

.cal-btn-danger {
  background: none;
  color: #ef4444;
  border: 1px solid #ef4444;
}

.cal-btn-danger:hover {
  background: rgba(239, 68, 68, 0.06);
}

/* Status badge in header */
.cal-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cal-status-badge.connected {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.cal-status-badge.disconnected {
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* Setup box */
.cal-setup-box {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--color-text-secondary);
}

.cal-setup-box strong {
  color: var(--color-text-primary);
  display: block;
  margin-bottom: 4px;
}

/* Client ID input */
.cal-client-id-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.cal-client-id-input {
  flex: 1;
  padding: 8px 11px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  font-size: 12px;
  transition: border-color 0.15s;
}

.cal-client-id-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Import results */
.cal-import-result {
  margin-top: 10px;
  padding: 9px 12px;
  background: var(--color-bg-secondary);
  border-radius: 7px;
  font-size: 12px;
  color: var(--color-text-secondary);
  border-left: 3px solid var(--color-border);
}

.cal-import-result.success {
  border-left-color: #10b981;
  color: #10b981;
}

.cal-import-result.error {
  border-left-color: #ef4444;
  color: #ef4444;
}

/* Export status */
.cal-export-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* GCal connected panel */
.gcal-connected-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gcal-status-text {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* Calendar sync trigger button (injected into UI) */
.cal-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}

.cal-trigger-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(79, 70, 229, 0.05);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .mission-control-sidebar {
    width: 100vw;
    right: -100vw;
  }

  .mc-toggle-btn.sidebar-open {
    right: 100vw;
  }

  .mc-toggle-label {
    display: none;
  }

  .mc-toggle-btn {
    padding: 12px 8px;
  }
}

@media (max-width: 480px) {
  .reminder-modal,
  .cal-sync-content {
    border-radius: 12px;
  }
}
