/* Long-recording local protection ----------------------------------------- */
.recovery-panel {
  margin-top: 18px;
  border-color: color-mix(in srgb, var(--blue) 34%, var(--border));
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--blue-soft) 50%, var(--surface)),
    var(--surface)
  );
}

.recovery-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.recovery-copy h2 {
  margin: 3px 0 8px;
  font-size: 1.05rem;
}

.recovery-copy p:last-child {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.recovery-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.recovery-actions .primary-button,
.recovery-actions .secondary-button {
  min-height: 42px;
  white-space: nowrap;
}

#previewPanel .download-actions {
  width: 100%;
  display: grid;
  gap: 10px;
}

#previewPanel .discard-stored-recording {
  width: 100%;
}

#previewPanel .discard-stored-recording[hidden] {
  display: none;
}

@media (max-width: 700px) {
  .recovery-copy {
    flex-direction: column;
    align-items: stretch;
  }

  .recovery-actions {
    width: 100%;
  }

  .recovery-actions .primary-button,
  .recovery-actions .secondary-button {
    flex: 1 1 0;
  }
}

html[data-theme="dark"] .recovery-panel {
  border-color: #355784;
  background: linear-gradient(145deg, #16233a, var(--surface));
}


/* Recovery panel layout polish */
.recovery-panel {
  padding: 22px 24px;
}

.recovery-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
}

.recovery-copy > div:first-child {
  min-width: 0;
}

.recovery-copy .section-kicker {
  margin-bottom: 8px;
}

.recovery-copy h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  line-height: 1.35;
}

.recovery-copy p:last-child {
  max-width: 760px;
  margin: 0;
  line-height: 1.6;
}

.recovery-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.recovery-actions .primary-button,
.recovery-actions .secondary-button {
  min-height: 42px;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .recovery-panel {
    padding: 20px;
  }

  .recovery-copy {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .recovery-actions {
    width: 100%;
    justify-content: stretch;
  }

  .recovery-actions .primary-button,
  .recovery-actions .secondary-button {
    flex: 1 1 0;
  }
}

@media (max-width: 460px) {
  .recovery-actions {
    flex-direction: column;
  }

  .recovery-actions .primary-button,
  .recovery-actions .secondary-button {
    width: 100%;
  }
}


/* Recorder section-title and destructive-action color consistency */
.panel-heading h2,
.status-heading h2 {
  color: var(--blue-dark);
}

/* Recovery discard is intentionally destructive. */
#discardRecoveryBtn {
  color: #ffffff;
  background: #dc3545;
  border-color: #dc3545;
  box-shadow: 0 8px 18px rgba(220, 53, 69, 0.18);
}

#discardRecoveryBtn:hover:not(:disabled) {
  color: #ffffff;
  background: #c92f3e;
  border-color: #c92f3e;
  box-shadow: 0 10px 20px rgba(220, 53, 69, 0.24);
}

#discardRecoveryBtn:active:not(:disabled) {
  background: #b92a38;
  border-color: #b92a38;
  box-shadow: none;
}

#discardRecoveryBtn:focus-visible {
  outline: 3px solid rgba(220, 53, 69, 0.24);
  outline-offset: 2px;
}

/* Prevent the general dark-theme secondary-button rule from muting
   the destructive recovery action. */
html[data-theme="dark"] #discardRecoveryBtn {
  color: #ffffff;
  background: #d94a58;
  border-color: #d94a58;
}

html[data-theme="dark"] #discardRecoveryBtn:hover:not(:disabled) {
  color: #ffffff;
  background: #e05865;
  border-color: #e05865;
}


/* Match recorder section titles to the LOCAL RECOVERY kicker style */
.panel-heading h2,
.status-heading h2 {
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1.3;
  text-transform: uppercase;
}


/* Recovered recording actions: primary download + destructive discard */
#previewPanel #downloadLink {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(47, 115, 241, 0.18);
  font-weight: 800;
  text-decoration: none;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

#previewPanel #downloadLink:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(47, 115, 241, 0.24);
  transform: translateY(-1px);
}

#previewPanel #downloadLink:active {
  transform: translateY(0);
  box-shadow: none;
}

#previewPanel #downloadLink:focus-visible {
  outline: 3px solid rgba(47, 115, 241, 0.24);
  outline-offset: 2px;
}

#previewPanel .discard-stored-recording {
  min-height: 46px;
  border: 1px solid #dc3545;
  border-radius: 10px;
  background: #dc3545;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(220, 53, 69, 0.16);
  font-weight: 800;
}

#previewPanel .discard-stored-recording:hover:not(:disabled) {
  border-color: #c92f3e;
  background: #c92f3e;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(220, 53, 69, 0.22);
  transform: translateY(-1px);
}

#previewPanel .discard-stored-recording:active:not(:disabled) {
  border-color: #b92a38;
  background: #b92a38;
  transform: translateY(0);
  box-shadow: none;
}

#previewPanel .discard-stored-recording:focus-visible {
  outline: 3px solid rgba(220, 53, 69, 0.24);
  outline-offset: 2px;
}

/* Keep the same action hierarchy in dark mode. */
html[data-theme="dark"] #previewPanel #downloadLink {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

html[data-theme="dark"] #previewPanel #downloadLink:hover {
  border-color: #4f86f7;
  background: #4f86f7;
  color: #ffffff;
}

html[data-theme="dark"] #previewPanel .discard-stored-recording {
  border-color: #d94a58;
  background: #d94a58;
  color: #ffffff;
}

html[data-theme="dark"] #previewPanel .discard-stored-recording:hover:not(:disabled) {
  border-color: #e05865;
  background: #e05865;
  color: #ffffff;
}


/* Final recovered-recording button styles.
   Exact IDs intentionally override older download/secondary-button rules. */
#downloadPanel #downloadLink {
  width: 100% !important;
  min-height: 48px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border: 1px solid #2f73f1 !important;
  border-radius: 10px;
  background: #2f73f1 !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(47, 115, 241, 0.18);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

#downloadPanel #downloadLink:hover {
  border-color: #1f5fd2 !important;
  background: #1f5fd2 !important;
  color: #ffffff !important;
  box-shadow: 0 10px 22px rgba(47, 115, 241, 0.24);
  transform: translateY(-1px);
}

#downloadPanel #downloadLink:active {
  transform: translateY(0);
  box-shadow: none;
}

#downloadPanel #discardStoredRecordingBtn {
  width: 100% !important;
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid #dc3545 !important;
  border-radius: 10px;
  background: #dc3545 !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(220, 53, 69, 0.18);
  font-weight: 800;
}

#downloadPanel #discardStoredRecordingBtn:hover:not(:disabled) {
  border-color: #c92f3e !important;
  background: #c92f3e !important;
  color: #ffffff !important;
  box-shadow: 0 10px 20px rgba(220, 53, 69, 0.24);
  transform: translateY(-1px);
}

#downloadPanel #discardStoredRecordingBtn:active:not(:disabled) {
  border-color: #b92a38 !important;
  background: #b92a38 !important;
  transform: translateY(0);
  box-shadow: none;
}

html[data-theme="dark"] #downloadPanel #downloadLink {
  border-color: #4f86f7 !important;
  background: #3f7df3 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] #downloadPanel #downloadLink:hover {
  border-color: #6798fb !important;
  background: #518af7 !important;
}

html[data-theme="dark"] #downloadPanel #discardStoredRecordingBtn {
  border-color: #d94a58 !important;
  background: #d94a58 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] #downloadPanel #discardStoredRecordingBtn:hover:not(:disabled) {
  border-color: #e05865 !important;
  background: #e05865 !important;
}


/* Consistent raised styling for main Screenio action buttons */
.primary-button,
#downloadPanel #downloadLink,
#previewPanel #downloadLink {
  background: linear-gradient(180deg, #3b82f6 0%, #286be8 100%) !important;
  border-color: #3478ef !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    0 10px 22px rgba(47, 115, 241, 0.22) !important;
}

.primary-button:hover:not(:disabled),
#downloadPanel #downloadLink:hover,
#previewPanel #downloadLink:hover {
  background: linear-gradient(180deg, #347bf6 0%, #205ed3 100%) !important;
  border-color: #286be8 !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 12px 25px rgba(47, 115, 241, 0.28) !important;
  transform: translateY(-1px);
}

.primary-button:active:not(:disabled),
#downloadPanel #downloadLink:active,
#previewPanel #downloadLink:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 3px rgba(18, 52, 116, 0.18),
    0 4px 10px rgba(47, 115, 241, 0.16) !important;
}

/* Neutral secondary actions keep the same depth without competing with primary actions. */
.secondary-button {
  background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
  border-color: var(--border-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 7px 16px rgba(29, 48, 78, 0.08);
}

.secondary-button:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffffff 0%, #edf3fb 100%);
  border-color: #96a7bf;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.90),
    0 9px 18px rgba(29, 48, 78, 0.11);
  transform: translateY(-1px);
}

.secondary-button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 3px rgba(29, 48, 78, 0.10),
    0 3px 8px rgba(29, 48, 78, 0.06);
}

/* Destructive actions use the same raised treatment in red. */
#discardRecoveryBtn,
#downloadPanel #discardStoredRecordingBtn,
#previewPanel .discard-stored-recording {
  background: linear-gradient(180deg, #ea5362 0%, #d63847 100%) !important;
  border-color: #dc3545 !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 9px 20px rgba(220, 53, 69, 0.22) !important;
}

#discardRecoveryBtn:hover:not(:disabled),
#downloadPanel #discardStoredRecordingBtn:hover:not(:disabled),
#previewPanel .discard-stored-recording:hover:not(:disabled) {
  background: linear-gradient(180deg, #e64a59 0%, #c92f3e 100%) !important;
  border-color: #c92f3e !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 11px 22px rgba(220, 53, 69, 0.28) !important;
  transform: translateY(-1px);
}

#discardRecoveryBtn:active:not(:disabled),
#downloadPanel #discardStoredRecordingBtn:active:not(:disabled),
#previewPanel .discard-stored-recording:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 3px rgba(104, 18, 27, 0.20),
    0 4px 9px rgba(220, 53, 69, 0.15) !important;
}

/* Dark mode keeps the same depth and hierarchy. */
html[data-theme="dark"] .primary-button,
html[data-theme="dark"] #downloadPanel #downloadLink,
html[data-theme="dark"] #previewPanel #downloadLink {
  background: linear-gradient(180deg, #4b8cff 0%, #2f73f1 100%) !important;
  border-color: #4b86f7 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 10px 24px rgba(25, 77, 177, 0.30) !important;
}

html[data-theme="dark"] .secondary-button {
  background: linear-gradient(180deg, #202b3d 0%, #182334 100%);
  border-color: #3a4960;
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 7px 16px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] .secondary-button:hover:not(:disabled) {
  background: linear-gradient(180deg, #26334a 0%, #1d2a3d 100%);
  border-color: #536782;
}

html[data-theme="dark"] #discardRecoveryBtn,
html[data-theme="dark"] #downloadPanel #discardStoredRecordingBtn,
html[data-theme="dark"] #previewPanel .discard-stored-recording {
  background: linear-gradient(180deg, #e35b68 0%, #c93e4b 100%) !important;
  border-color: #d94a58 !important;
  color: #ffffff !important;
}


/* Natural recovered-recording action layout */
#downloadPanel.download-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 24px;
}

#previewPanel .download-actions {
  width: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

#downloadPanel #downloadLink {
  width: auto !important;
  min-width: 200px;
  min-height: 44px;
  padding: 9px 18px;
}

#downloadPanel #discardStoredRecordingBtn {
  width: auto !important;
  min-width: 160px;
  min-height: 44px;
  padding: 9px 18px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  #downloadPanel.download-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  #previewPanel .download-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  #previewPanel .download-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  #downloadPanel #downloadLink,
  #downloadPanel #discardStoredRecordingBtn {
    width: 100% !important;
    min-width: 0;
  }
}


/* Recording control: Stop uses the destructive red action treatment. */
#recorderStatus #recordToggleBtn.is-stop {
  background: linear-gradient(180deg, #ea5362 0%, #d63847 100%) !important;
  border-color: #dc3545 !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 10px 22px rgba(220, 53, 69, 0.24) !important;
}

#recorderStatus #recordToggleBtn.is-stop:hover:not(:disabled) {
  background: linear-gradient(180deg, #e64a59 0%, #c92f3e 100%) !important;
  border-color: #c92f3e !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 12px 24px rgba(220, 53, 69, 0.30) !important;
  transform: translateY(-1px);
}

#recorderStatus #recordToggleBtn.is-stop:active:not(:disabled) {
  background: linear-gradient(180deg, #d94351 0%, #b92a38 100%) !important;
  border-color: #b92a38 !important;
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 3px rgba(104, 18, 27, 0.22),
    0 4px 10px rgba(220, 53, 69, 0.16) !important;
}

#recorderStatus #recordToggleBtn.is-stop:focus-visible {
  outline: 3px solid rgba(220, 53, 69, 0.26);
  outline-offset: 2px;
}

html[data-theme="dark"] #recorderStatus #recordToggleBtn.is-stop {
  background: linear-gradient(180deg, #e35b68 0%, #c93e4b 100%) !important;
  border-color: #d94a58 !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 24px rgba(120, 20, 35, 0.34) !important;
}

html[data-theme="dark"] #recorderStatus #recordToggleBtn.is-stop:hover:not(:disabled) {
  background: linear-gradient(180deg, #e96773 0%, #d44754 100%) !important;
  border-color: #e05865 !important;
}
