/* ────────────────────────────────────────────────────────────────────── */
/*  FORCE‑SHOW OVERRIDE & BASE STYLES                                    */
/* ────────────────────────────────────────────────────────────────────── */

/* 1) Ensure they’re hidden by default, no matter what came before */
#cpn-history-overlay,
#cpn-history-modal {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* 2) When .show is toggled, force them fully visible above everything */
#cpn-history-overlay.show {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 99999 !important;
}

#cpn-history-modal.show {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 100000 !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(1) !important;
}

/* ────────────────────────────────────────────────────────────────────── */
/*  YOUR MODAL & OVERLAY STYLES                                          */
/* ────────────────────────────────────────────────────────────────────── */

/* Variables for easy theming */
:root {
  --modal-width:      95%;
  --modal-max-width:  60vw;
  --modal-max-height: 90vh;
  --overlay-color:    rgba(0,0,0,0.6);
  --modal-bg:         #fff;
  --header-bg:        #fafafa;
  --footer-bg:        #fafafa;
  --border-color:     #e0e0e0;
  --text-color:       #333;
  --radius:           8px;
  --shadow:           0 12px 24px rgba(0,0,0,0.15);
  --font-stack:       system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --btn-bg:           #006666;
  --btn-hover:        #005177;
  --btn-color:        #fff;
  --transition-fast:  0.2s ease-out;
}

/* Overlay */
#cpn-history-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-color);
  transition: opacity var(--transition-fast);
}

/* Modal box */
#cpn-history-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: var(--modal-width);
  max-width: var(--modal-max-width);
  max-height: var(--modal-max-height);
  background: var(--modal-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  font-family: var(--font-stack);
  color: var(--text-color);
}

/* Header */
.cpn-modal__titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
}
.cpn-modal__titlebar h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}
.cpn-modal__titlebar button {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #666;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color var(--transition-fast);
}
.cpn-modal__titlebar button:hover {
  color: #333;
}

/* Body */
.cpn-modal__body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  max-height: calc(var(--modal-max-height) - 140px);
}

/* Footer */
.cpn-modal__actions {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.25rem;
  background: var(--footer-bg);
  border-top: 1px solid var(--border-color);
}
.cpn-modal__actions button {
  padding: 0.5rem 1.2rem;
  background: var(--btn-bg);
  border: none;
  border-radius: calc(var(--radius)/2);
  color: var(--btn-color);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.cpn-modal__actions button:hover {
  background: var(--btn-hover);
}

/* Utility states */
.cpn-loading {
  text-align: center;
  color: #666;
  margin: 2rem 0;
}
.cpn-error {
  text-align: center;
  color: #c00;
  margin: 2rem 0;
}

/* ────────────────────────────────────────────────────────────────────── */
/*  Responsive tweaks                                                    */
/* ────────────────────────────────────────────────────────────────────── */

/* Large screens */
@media (min-width: 1200px) {
  :root { --modal-width: 70vw; }
}

/* Mobile full‑screen */
@media (max-width: 400px) {
  #cpn-history-modal {
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    max-height: none;
    border-radius: 0 !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
  }
  .cpn-modal__body   { padding: 0.75rem; }
  .cpn-modal__titlebar,
  .cpn-modal__actions { padding: 0.5rem; }
}

/* Tablet padding boost */
@media (min-width: 600px) and (max-width: 1199px) {
  .cpn-modal__body     { padding: 1.5rem; }
  .cpn-modal__titlebar { padding: 1rem 1.5rem; }
  .cpn-modal__actions  { padding: 1rem 1.5rem; }
}