/**
 * Manage Saves Modal Styles
 */

.manage-saves-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

.manage-saves-overlay.hidden { display: none; }

.manage-saves-modal {
  background: var(--bg-surface, #1a1e24);
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Header */
.manage-saves-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.manage-saves-header h3 {
  margin: 0;
  font-size: 0.95em;
  font-weight: 500;
  color: var(--text-secondary, #a8a5a0);
}

.manage-saves-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.manage-saves-close,
.manage-saves-drive-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-secondary, #a8a5a0);
  cursor: pointer; border-radius: 5px; transition: all 0.15s;
}

.manage-saves-close:hover,
.manage-saves-drive-btn:hover {
  color: var(--text-primary, #e6e4e0);
  background: var(--bg-elevated, #22272e);
}

/* Body */
.manage-saves-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.manage-saves-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #a8a5a0);
  font-size: 0.88em;
}

/* Bottom row: [+ New Named Save] [⋮] */
.ms-bottom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 16px 4px;
}

.ms-bottom-more-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border-radius: 5px; border: none;
  background: transparent;
  color: var(--text-secondary, #a8a5a0);
  cursor: pointer; transition: all 0.15s;
}

.ms-bottom-more-btn .material-icons { font-size: 20px; }
.ms-bottom-more-btn:hover { background: var(--bg-elevated, #22272e); color: var(--text-primary, #e6e4e0); }

/* New Named Save button */
.ms-new-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 10px 16px;
  color: var(--accent-warm, #c4a35a);
  font-size: 0.85em;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(196, 163, 90, 0.35);
  border-radius: 7px;
  background: rgba(196, 163, 90, 0.06);
  width: calc(100% - 32px);
  text-align: center;
  transition: all 0.15s;
  min-height: 44px;
}

.ms-new-row .material-icons { font-size: 17px; }

.ms-new-row:hover {
  background: rgba(196, 163, 90, 0.12);
  border-color: rgba(196, 163, 90, 0.55);
}

/* Save row */
.ms-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 10px 0;
  min-height: 44px;
  margin: 0 8px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  position: relative;
}

.ms-row:last-child { border-bottom: none; }
.ms-row.from-device { opacity: 0.7; }

/* Colored left bar — autosave=green, quicksave=blue, named=none */
.ms-type-bar {
  width: 3px;
  height: 44px;
  border-radius: 2px;
  flex-shrink: 0;
}

.ms-bar-auto  { background: #4caf50; }
.ms-bar-quick { background: #2196f3; }
.ms-bar-none  { background: transparent; }

/* Row content */
.ms-row-info { flex: 1; min-width: 0; }

.ms-row-name {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--text-primary, #e6e4e0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.ms-row-time {
  display: block;
  font-size: 0.75em;
  color: var(--text-secondary, #a8a5a0);
  white-space: nowrap;
}

/* Cloud button — standalone flex item between info and ⋮ menu */
.ms-cloud-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.15s;
}

.ms-cloud-pill:hover { background: rgba(255, 255, 255, 0.08); }
.ms-cloud-pill .material-icons { font-size: 16px; }

.cloud-synced      { color: #4caf50; }
.cloud-upload      { color: var(--accent-warm, #c4a35a); }
.cloud-download    { color: #2196f3; }
.cloud-unconnected { color: var(--text-secondary, #a8a5a0); }

/* Actions */
.ms-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Context menu button */
.ms-more-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px; border: none;
  background: transparent;
  color: var(--text-secondary, #a8a5a0);
  cursor: pointer; transition: all 0.15s;
}

.ms-more-btn .material-icons { font-size: 20px; }

.ms-more-btn:hover {
  background: var(--bg-elevated, #22272e);
  color: var(--text-primary, #e6e4e0);
}

/* Portal dropdown — fixed to body, clears footer */
.ms-dropdown {
  display: none;
  position: fixed;
  background: var(--bg-elevated, #22272e);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 20000;
  min-width: 200px;
  overflow: hidden;
}

.ms-dropdown.open { display: block; }

/* Cloud status header inside dropdown */
.ms-dropdown-cloud-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px 7px;
  font-size: 0.78em;
  font-weight: 500;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  margin-bottom: 2px;
}

.ms-dropdown-cloud-status .material-icons { font-size: 14px; }

.ms-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-primary, #e6e4e0);
  font-size: 0.83em;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}

.ms-dropdown-item .material-icons {
  font-size: 15px;
  color: var(--text-secondary, #a8a5a0);
}

.ms-dropdown-item:hover { background: var(--bg-surface, #1a1e24); }
.ms-dropdown-item.danger { color: #f44336; }
.ms-dropdown-item.danger .material-icons { color: #f44336; }

.ms-drive-hint {
  margin-left: auto;
  font-size: 0.83em;
  opacity: 0.8;
  color: var(--text-secondary, #a8a5a0);
  font-style: italic;
}

.ms-dropdown-divider {
  height: 1px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.ms-dropdown-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 6px;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #a8a5a0);
  pointer-events: none;
  user-select: none;
}

/* Load button — ghost */
.ms-load-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  background: transparent;
  color: var(--text-secondary, #a8a5a0);
  font-size: 0.82em;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.ms-load-btn:hover {
  color: var(--text-primary, #e6e4e0);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Save button — primary warm */
.ms-save-btn {
  height: 44px;
  padding: 0 16px;
  border-radius: 5px;
  border: none;
  background: var(--accent-warm, #c4a35a);
  color: #000;
  font-weight: 600;
  font-size: 0.82em;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.ms-save-btn:hover { opacity: 0.85; }

/* ─── Sync Modal ─────────────────────────────────────────────────────────── */

.sm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 16px;
}

.sm-overlay.hidden { display: none; }

.sm-modal {
  background: var(--bg-surface, #1a1e24);
  border-radius: 12px;
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.sm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
  gap: 8px;
}

.sm-col-label {
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #a8a5a0);
}

.sm-col-label:last-child { text-align: right; }

.sm-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; flex-shrink: 0;
  color: var(--text-secondary, #a8a5a0);
  cursor: pointer; border-radius: 5px; transition: all 0.15s;
}

.sm-close:hover { background: var(--bg-elevated, #22272e); color: var(--text-primary, #e6e4e0); }
.sm-close .material-icons { font-size: 18px; }

.sm-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.sm-row {
  display: grid;
  grid-template-columns: 1fr 56px 1fr 40px;
  align-items: center;
  min-height: 56px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-left: 3px solid transparent;
  transition: background 0.1s;
}
.sm-row[data-type="autosave"]  { border-left-color: #4caf50; }
.sm-row[data-type="quicksave"] { border-left-color: #2196f3; }

.sm-row:last-child { border-bottom: none; }
.sm-row.sm-synced { opacity: 0.5; }

.sm-cell {
  padding: 10px 12px;
  cursor: pointer;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: background 0.1s;
}

.sm-cell:hover { background: rgba(255, 255, 255, 0.04); }

.sm-cell[data-side="drive"] {
  text-align: right;
  align-items: flex-end;
}

.sm-cell-empty {
  cursor: default;
  opacity: 0.4;
}

.sm-cell-empty:hover { background: none; }

.sm-cell-absent {
  font-size: 0.73em;
  color: var(--text-secondary, #a8a5a0);
  font-style: italic;
}

.sm-cell-name {
  font-size: 0.85em;
  font-weight: 500;
  color: var(--text-primary, #e6e4e0);
  margin-bottom: 2px;
}

.sm-cell-time {
  font-size: 0.72em;
  color: var(--text-secondary, #a8a5a0);
}

.sm-cell-moves {
  font-size: 0.72em;
  font-style: italic;
  opacity: 0.65;
  margin-top: 1px;
}

/* "All" button in header — looks like a tappable chip */
.sm-all-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  white-space: nowrap;
}

.sm-all-btn:hover { background: rgba(255, 255, 255, 0.1); }

.sm-all-label {
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #a8a5a0);
}

.sm-all-icon { font-size: 20px; }

.sm-col-right { text-align: right; }

/* Moves count on separate line below date in save rows */
.ms-row-moves {
  display: block;
  font-size: 0.7em;
  font-style: italic;
  opacity: 0.65;
  color: var(--text-secondary, #a8a5a0);
  margin-top: 1px;
}

.sm-arrow-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.sm-arrow-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  cursor: pointer; border-radius: 50%;
  transition: background 0.15s;
  position: relative;
}

.sm-arrow-btn:hover { background: rgba(255, 255, 255, 0.08); }
.sm-arrow-btn .material-icons { font-size: 20px; }

.sm-delete-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.sm-delete-btn:hover {
  background: rgba(244, 67, 54, 0.12);
  color: #f44336;
}

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



.sm-warn-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.55em;
  font-weight: 800;
  color: #f44336;
  line-height: 1;
}

.sm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.sm-cancel-btn {
  height: 44px; padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  background: transparent;
  color: var(--text-secondary, #a8a5a0);
  font-size: 0.85em; cursor: pointer;
  transition: all 0.15s;
}

.sm-cancel-btn:hover { color: var(--text-primary, #e6e4e0); border-color: rgba(255,255,255,0.2); }

.sm-sync-btn {
  height: 44px; padding: 0 20px;
  border-radius: 6px;
  border: none;
  background: var(--accent-warm, #c4a35a);
  color: #000;
  font-weight: 600;
  font-size: 0.85em;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sm-sync-btn:hover { opacity: 0.85; }
.sm-sync-btn:disabled { opacity: 0.4; cursor: default; }

.sm-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary, #a8a5a0);
}

.sm-empty {
  text-align: center;
  padding: 32px 20px;
  font-size: 0.88em;
  color: var(--text-secondary, #a8a5a0);
}

.sm-error { color: #f44336; }

.sm-progress-list {
  padding: 4px 0;
}
.sm-progress-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 16px;
  font-size: 0.82em;
  color: var(--text-secondary, #999);
}
.sm-progress-item .material-icons { font-size: 17px; margin-top: 1px; flex-shrink: 0; }
.sm-progress-label small { opacity: 0.7; font-size: 0.88em; }
.sm-progress-ok  { color: #4caf50; }
.sm-progress-err { color: #f44336; }
.sm-progress-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 0.9em;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sm-progress-summary .material-icons { font-size: 22px; }

.sm-game-header {
  padding: 8px 12px 5px;
  font-size: 0.68em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-warm, #c4a35a);
  background: var(--bg-elevated, #22272e);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sm-game-header:not(:first-child) {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 4px;
}

@keyframes sm-spin { to { transform: rotate(360deg); } }
.sm-spin { display: inline-block; animation: sm-spin 1s linear infinite; }

/* ─────────────────────────────────────────────────────────────────────────── */

/* Cloud icon sync animation */
@keyframes ms-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ms-cloud-dot.syncing .material-icons,
.ms-cloud-pill.syncing .material-icons {
  animation: ms-spin 1s linear infinite;
  color: var(--text-secondary, #a8a5a0);
}

/* Backup rows — inline expand below parent save row */
.ms-backup-section {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
}

.ms-backup-section.open { max-height: 400px; }

.ms-backup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 32px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
  background: rgba(0, 0, 0, 0.15);
  min-height: 44px;
}

.ms-backup-row:last-child { border-bottom: none; }

.ms-backup-tick {
  width: 2px; height: 28px;
  border-radius: 1px;
  background: var(--bg-elevated, #22272e);
  flex-shrink: 0;
}

.ms-backup-info { flex: 1; min-width: 0; }

.ms-backup-time {
  font-size: 0.76em;
  color: var(--text-secondary, #a8a5a0);
}

.ms-backup-moves {
  font-size: 0.7em;
  font-style: italic;
  opacity: 0.65;
  color: var(--text-secondary, #a8a5a0);
  margin-top: 1px;
}

.ms-backup-load {
  height: 44px;
  padding: 0 12px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  background: transparent;
  color: var(--text-secondary, #a8a5a0);
  font-size: 0.78em;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.ms-backup-load:hover {
  color: var(--text-primary, #e6e4e0);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Footer — hidden, utility actions moved to bottom ⋮ menu */
.manage-saves-footer {
  display: none;
}

.manage-saves-footer-hidden {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.manage-saves-import-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  color: var(--text-secondary, #a8a5a0);
  cursor: pointer;
  font-size: 0.82em;
  transition: all 0.15s;
}

.manage-saves-import-btn .material-icons { font-size: 16px; }

.manage-saves-import-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary, #e6e4e0);
}

/* Inline save name form — replaces + Save Game button on click */
.ms-new-row-form {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.ms-new-input {
  flex: 1;
  height: 44px;
  padding: 0 12px;
  background: var(--bg-elevated, #22272e);
  border: 1px solid var(--accent-warm, #c4a35a);
  border-radius: 7px;
  color: var(--text-primary, #e6e4e0);
  font-size: 0.88em;
  outline: none;
}

.ms-new-confirm {
  height: 44px;
  padding: 0 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent-warm, #c4a35a);
  color: #000;
  font-weight: 600;
  font-size: 0.82em;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.ms-new-confirm:hover { opacity: 0.85; }

.ms-new-cancel {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #a8a5a0);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ms-new-cancel:hover { background: var(--bg-elevated, #22272e); }
.ms-new-cancel .material-icons { font-size: 16px; }

/* Connect Drive — same row as Import, only shown when not signed in */
.ms-connect-drive {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  color: var(--text-secondary, #a8a5a0);
  font-size: 0.82em;
  cursor: pointer;
  transition: all 0.15s;
}

.ms-connect-drive .material-icons { font-size: 16px; }
.ms-connect-drive:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary, #e6e4e0);
}
