/* ================================================================
   ModulePageShell — App/Settings tab wrapper
   ================================================================ */

.module-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-bg, #f8f9fa);
}

.module-shell--no-tabs {
  /* When no settings access, content fills entire area */
  height: 100%;
}

/* ── Tab Bar ─────────────────────────────────────────────────── */

.module-shell__tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--color-surface, #fff);
  border-bottom: 1px solid var(--color-border, #e0e0e0);
  flex-shrink: 0;
}

.module-shell__tab {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.module-shell__tab:hover {
  color: var(--color-primary, #2C5CA3);
}

.module-shell__tab--active {
  color: var(--color-primary, #2C5CA3);
  border-bottom-color: var(--color-primary, #2C5CA3);
}

/* ── Content Area ────────────────────────────────────────────── */

.module-shell__content {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.module-shell__empty,
.module-shell__error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--color-text-secondary, #888);
  text-align: center;
}

.module-shell__error {
  color: #c53030;
}

/* ── Automation Info Banner ───────────────────────────────────── */

.module-shell__automation-info {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.module-shell__automation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  height: 100%;
  min-height: 300px;
}

.module-shell__automation-icon {
  color: var(--color-text-secondary, #888);
  opacity: 0.4;
  margin-bottom: 16px;
}

.module-shell__automation-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text, #444);
  margin: 0 0 8px;
}

.module-shell__automation-desc {
  font-size: 14px;
  color: var(--color-text-secondary, #888);
  margin: 0 0 24px;
}

.module-shell__automation-schedule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  font-size: 13px;
  color: var(--color-text, #444);
}

.module-shell__automation-label {
  font-weight: 500;
  color: var(--color-primary, #2C5CA3);
}

/* ── Run Button & Result ────────────────────────────────────── */

.module-shell__run-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary, #2C5CA3);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.module-shell__run-btn:hover {
  opacity: 0.9;
}

.module-shell__run-btn--running {
  opacity: 0.7;
  cursor: wait;
}

.module-shell__spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: shell-spin 0.6s linear infinite;
}

@keyframes shell-spin {
  to { transform: rotate(360deg); }
}

.module-shell__run-result {
  width: 100%;
  max-width: 420px;
  margin-top: 16px;
  text-align: left;
}

.module-shell__run-card {
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--color-border, #e0e0e0);
  background: var(--color-surface, #fff);
}

.module-shell__run-card--success {
  border-color: var(--color-accent, #20B685);
  background: rgba(32, 182, 133, 0.04);
}

.module-shell__run-card--error {
  border-color: #c53030;
  background: rgba(197, 48, 48, 0.04);
}

.module-shell__run-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text, #444);
}

.module-shell__run-icon {
  font-size: 16px;
  font-weight: 700;
}

.module-shell__run-icon--success {
  color: var(--color-accent, #20B685);
}

.module-shell__run-icon--error {
  color: #c53030;
}

.module-shell__run-steps {
  margin-top: 10px;
  padding-left: 4px;
  font-size: 13px;
  font-family: monospace;
  color: var(--color-text, #444);
}

.module-shell__run-step {
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.8;
}

.module-shell__run-step-line {
  color: var(--color-text-secondary, #888);
  margin-right: 2px;
}

.module-shell__run-step-status--ok {
  color: var(--color-accent, #20B685);
  font-weight: 500;
}

.module-shell__run-step-status--fail {
  color: #c53030;
  font-weight: 500;
}

.module-shell__run-step-dur {
  color: var(--color-text-secondary, #888);
}

.module-shell__run-error {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(197, 48, 48, 0.06);
  border-radius: 4px;
  font-size: 13px;
  color: #c53030;
  word-break: break-word;
}

/* ── Error Recovery UI ───────────────────────────────────── */

.module-shell__error-recovery {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  height: 100%;
  min-height: 300px;
}

.module-shell__error-recovery-icon {
  margin-bottom: 16px;
  opacity: 0.7;
}

.module-shell__error-recovery h3 {
  font-size: 18px;
  font-weight: 600;
  color: #c53030;
  margin: 0 0 8px;
}

.module-shell__error-recovery-msg {
  font-size: 14px;
  color: var(--color-text-secondary, #888);
  margin: 0 0 16px;
}

.module-shell__error-recovery-detail {
  max-width: 480px;
  padding: 12px 16px;
  background: rgba(197, 48, 48, 0.06);
  border: 1px solid rgba(197, 48, 48, 0.15);
  border-radius: 6px;
  font-size: 12px;
  color: #c53030;
  word-break: break-word;
  white-space: pre-wrap;
  text-align: left;
  margin: 0 0 16px;
}

.module-shell__error-recovery-hint {
  font-size: 13px;
  color: var(--color-text-secondary, #888);
  margin: 0 0 20px;
  max-width: 400px;
}

.module-shell__error-recovery-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary, #2C5CA3);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.module-shell__error-recovery-btn:hover {
  opacity: 0.9;
}

/* ── Dark Theme ──────────────────────────────────────────────── */

[data-theme="dark"] .module-shell__tabs {
  background: var(--color-surface, #1e1e1e);
  border-bottom-color: var(--color-border, #333);
}

[data-theme="dark"] .module-shell__tab {
  color: var(--color-text-secondary, #999);
}

[data-theme="dark"] .module-shell__tab:hover,
[data-theme="dark"] .module-shell__tab--active {
  color: var(--color-primary, #5b9bd5);
}

[data-theme="dark"] .module-shell__tab--active {
  border-bottom-color: var(--color-primary, #5b9bd5);
}

[data-theme="dark"] .module-shell__automation-schedule {
  background: var(--color-surface, #1e1e1e);
  border-color: var(--color-border, #333);
}

[data-theme="dark"] .module-shell__run-card {
  background: var(--color-surface, #1e1e1e);
  border-color: var(--color-border, #333);
}

[data-theme="dark"] .module-shell__run-card--success {
  border-color: var(--color-accent, #20B685);
  background: rgba(32, 182, 133, 0.08);
}

[data-theme="dark"] .module-shell__run-card--error {
  border-color: #fc8181;
  background: rgba(197, 48, 48, 0.08);
}

[data-theme="dark"] .module-shell__run-status {
  color: var(--color-text, #e0e0e0);
}

[data-theme="dark"] .module-shell__run-steps {
  color: var(--color-text, #e0e0e0);
}

[data-theme="dark"] .module-shell__error-recovery h3 {
  color: #fc8181;
}

[data-theme="dark"] .module-shell__error-recovery-detail {
  background: rgba(197, 48, 48, 0.12);
  border-color: rgba(252, 129, 129, 0.2);
  color: #fc8181;
}

[data-theme="dark"] .module-shell__run-error {
  background: rgba(197, 48, 48, 0.12);
  color: #fc8181;
}

[data-theme="dark"] .module-shell__spinner {
  border-color: rgba(255,255,255,0.2);
  border-top-color: #fff;
}

/* ── Mobile (640px) ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .module-shell__tabs {
    padding: 0 12px;
  }

  .module-shell__tab {
    padding: 10px 16px;
    font-size: 13px;
  }

  .module-shell__automation {
    padding: 32px 16px;
  }
}
