/* PatriotChat cookie consent UI
   Canonical stylesheet (deduplicated)
   - Banner (large + small)
   - Consent modal
   - Layout protection for page content + DM composer
*/

:root {
  --pc-cookie-z: 9999;
  --pc-cookie-overlay-z: 10000;
  --pc-cookie-page-pad: 140px;
  --pc-cookie-dm-offset: 168px;
}

/* Banner */
#cookie-banner {
  position: fixed;
  z-index: var(--pc-cookie-z);
  background: #1e1e1e;
  color: #eee;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
  transition: all 0.35s ease-in-out;
}

#cookie-banner.cookie-banner-large {
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  width: auto;
  max-width: min(760px, calc(100vw - 24px));
}

#cookie-banner.cookie-banner-small {
  right: 1rem;
  left: auto;
  bottom: 2.5rem;
  transform: none;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  white-space: nowrap;
  min-width: 320px;
  max-width: min(420px, calc(100vw - 24px));
}

#cookie-banner .top-row,
#cookie-banner .btn-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#cookie-banner .details {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.85rem;
  color: #bbb;
}

#cookie-banner.cookie-banner-small .details {
  display: none;
}

#cookie-banner .label {
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

#cookie-banner .manage-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

#cookie-banner .manage-btn:hover {
  color: #fff;
}

/* Keep cookie banner buttons stable regardless of global button CSS. */
#cookie-banner .btn {
  display: inline-block !important;
  margin: 0 !important;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid #555;
  border-radius: 5px;
  background: #333;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

#cookie-banner .btn:hover {
  background: #444;
}

#cookie-banner .btn-primary {
  background: #007bff;
  border-color: #007bff;
}

#cookie-banner .btn-primary:hover {
  background: #0056b3;
  border-color: #0056b3;
}

/* Keep non-DM page content visible above the banner. */
body.has-cookie-banner:not(.dm-page) main {
  padding-bottom: max(var(--pc-cookie-page-pad), calc(88px + env(safe-area-inset-bottom, 0px)));
}

/* DMs: JS computes this variable from live composer geometry. */
body.dm-page #cookie-banner.cookie-banner-large,
body.dm-page #cookie-banner.cookie-banner-small {
  bottom: calc(var(--pc-cookie-dm-offset) + env(safe-area-inset-bottom, 0px)) !important;
}

/* Modal overlay */
.cookie-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--pc-cookie-overlay-z);
  background: rgba(0, 0, 0, 0.55);
  display: none;
  place-items: center;
}

.cookie-overlay.show {
  display: grid !important;
}

.cookie-modal {
  position: relative;
  background: #1e1e1e;
  color: #eee;
  width: 90%;
  max-width: 480px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.75rem 2rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}

.cookie-modal h3 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.cookie-modal label {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0.6rem 0;
  font-size: 0.95rem;
}

#prefSaveBtn {
  margin-top: 1rem;
  background: #007bff;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

#prefSaveBtn:hover {
  opacity: 0.9;
}

.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: #bbb;
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.hidden {
  display: none !important;
}

/* Mobile */
@media (max-width: 600px) {
  :root {
    --pc-cookie-page-pad: 128px;
  }

  #cookie-banner.cookie-banner-large {
    flex-direction: column;
    align-items: flex-start;
    width: auto;
    max-width: calc(100vw - 16px);
  }

  #cookie-banner.cookie-banner-large .btn-row {
    width: 100%;
  }

  #cookie-banner.cookie-banner-large .btn {
    width: 100%;
  }

  #cookie-banner.cookie-banner-small {
    right: 0.5rem;
    left: 0.5rem;
    min-width: 0;
    max-width: none;
  }

  #cookie-banner .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.65rem;
  }

  #cookie-banner .label {
    font-size: 0.9rem;
  }

  body.dm-page #cookie-banner.cookie-banner-large,
  body.dm-page #cookie-banner.cookie-banner-small {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    transform: none;
    max-width: none;
  }
}
