/**
 * DineDash Legal & Policies Unified Stylesheet
 * Responsive, accessible typography, card containers, and clean print styles.
 * Uses DineDash Master Teal Theme (#00C896, #0D9A78, #0F1923).
 */

:root {
  --teal-primary: #00C896;
  --teal-dark: #0D9A78;
  --teal-darker: #0A7A5E;
  --teal-light: #4DDEBC;
  --teal-soft: #E6FBF5;
  --navy-dark: #0F1923;
  --slate-bg: #F8FAFC;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border-light: #E2E8F0;
  --border-teal: rgba(0, 200, 150, 0.25);
}

/* Container */
.legal-page-wrapper {
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px 20px 60px 20px;
}

/* Top Action Header */
.legal-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.legal-header-title-group h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--navy-dark);
  margin: 0 0 6px 0;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.legal-header-title-group h1 i {
  color: var(--teal-dark);
  font-size: 1.6rem;
}

.legal-header-title-group p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.legal-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Button Styles */
.btn-legal-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-legal-back {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-light);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.btn-legal-back:hover {
  background: #F1F5F9;
  color: var(--navy-dark);
  border-color: #CBD5E1;
  text-decoration: none;
}

.btn-legal-print {
  background: var(--teal-soft);
  color: var(--teal-darker);
  border-color: var(--border-teal);
}

.btn-legal-print:hover {
  background: #D4F7EE;
  color: #055E48;
  border-color: var(--teal-primary);
}

/* Meta Card */
.legal-doc-meta-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.legal-meta-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legal-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legal-badge-teal {
  background: var(--teal-soft);
  color: var(--teal-darker);
  border: 1px solid var(--border-teal);
}

.legal-badge-neutral {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.legal-meta-dates {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legal-meta-dates .meta-label {
  font-weight: 500;
  color: #64748B;
}

.legal-meta-dates .meta-value {
  font-weight: 700;
  color: var(--navy-dark);
}

.legal-meta-divider {
  color: #CBD5E1;
}

/* Main Legal Body Card */
.legal-body-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 36px 40px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
  line-height: 1.75;
  color: #334155;
  font-size: 0.98rem;
}

@media (max-width: 768px) {
  .legal-body-card {
    padding: 24px 20px;
  }
}

/* Callouts */
.legal-callout {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 28px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.legal-callout-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.legal-callout-info {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #166534;
}

.legal-callout-info .legal-callout-icon {
  color: var(--teal-dark);
}

.legal-callout-teal {
  background: var(--teal-soft);
  border: 1px solid var(--border-teal);
  color: #065F46;
}

.legal-callout-teal .legal-callout-icon {
  color: var(--teal-darker);
}

.legal-callout-neutral {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  color: #475569;
  padding: 12px 16px;
  margin-top: 14px;
  font-size: 0.88rem;
}

/* Sections */
.legal-section {
  margin-bottom: 34px;
  padding-bottom: 24px;
  border-bottom: 1px solid #F1F5F9;
}

.legal-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.legal-section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy-dark);
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.legal-section-title .sec-num {
  color: var(--teal-dark);
}

.legal-subheading {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1E293B;
  margin: 18px 0 10px 0;
}

.legal-list {
  padding-left: 22px;
  margin: 12px 0 16px 0;
}

.legal-list li {
  margin-bottom: 8px;
}

.legal-emphasis {
  font-weight: 600;
  color: #0F1923;
}

/* Contact Box */
.legal-contact-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 4px solid var(--teal-primary);
  border-radius: 8px;
  padding: 18px 22px;
  margin-top: 16px;
}

.legal-contact-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 10px;
}

.legal-contact-details p {
  margin: 4px 0;
  font-size: 0.9rem;
}

.legal-contact-details a {
  color: var(--teal-dark);
  font-weight: 600;
  text-decoration: underline;
}

.legal-contact-details a:hover {
  color: var(--teal-darker);
}

/* Customer Panel Standalone View Specifics */
.customer-legal-header {
  background: #ffffff;
  border-bottom: 1px solid #E2E8F0;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.customer-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.customer-brand-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

/* ==========================================================================
   Customer Legal Policy Modal Popup
   ========================================================================== */
.legal-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 35, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100000; /* Stays above #auth-screen (z-index: 9999) and all page elements */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.legal-modal-backdrop.active {
  display: flex !important;
  opacity: 1;
}

body.dd-legal-modal-open,
html.dd-legal-modal-open {
  overflow: hidden !important;
  touch-action: none;
}

.legal-modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 200, 150, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.legal-modal-backdrop.active .legal-modal-dialog {
  transform: translateY(0) scale(1);
}

@media (max-width: 640px) {
  .legal-modal-backdrop {
    padding: 8px;
  }
  .legal-modal-dialog {
    max-height: 96vh;
    border-radius: 16px;
  }
}

.legal-modal-header {
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.legal-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.legal-modal-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #E6FBF5;
  color: #0D9A78;
  border: 1px solid rgba(0, 200, 150, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.legal-modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0F1923;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.legal-modal-subtitle {
  font-size: 0.78rem;
  color: #64748B;
  font-weight: 500;
  display: block;
  margin-top: 2px;
}

.legal-modal-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  color: #334155;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  pointer-events: auto;
}

.legal-modal-close-btn i {
  pointer-events: none;
}

.legal-modal-close-btn:hover,
.legal-modal-close-btn:focus-visible {
  background: #E2E8F0;
  color: #0F1923;
  border-color: #94A3B8;
  outline: 2px solid #00C896;
}

.legal-modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex-grow: 1;
  line-height: 1.7;
  color: #334155;
  font-size: 0.94rem;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 200, 150, 0.45) #F1F5F9;
}

.legal-modal-body::-webkit-scrollbar {
  width: 6px;
}
.legal-modal-body::-webkit-scrollbar-track {
  background: #F8FAFC;
}
.legal-modal-body::-webkit-scrollbar-thumb {
  background: #00C896;
  border-radius: 6px;
}

@media (max-width: 640px) {
  .legal-modal-header {
    padding: 12px 14px;
  }
  .legal-modal-title {
    font-size: 1.05rem;
  }
  .legal-modal-icon-badge {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .legal-modal-body {
    padding: 16px 14px;
    font-size: 0.88rem;
  }
}

.legal-modal-footer {
  padding: 12px 20px;
  background: #F8FAFC;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

.legal-modal-footer-note {
  font-size: 0.78rem;
  color: #64748B;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legal-modal-footer-btn {
  padding: 9px 22px;
  background: #0F1923;
  color: #ffffff;
  border: 1px solid #1E293B;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
}

.legal-modal-footer-btn:hover {
  background: #1E293B;
  border-color: #334155;
}

@media (max-width: 640px) {
  .legal-modal-footer-note {
    display: none;
  }
  .legal-modal-footer {
    justify-content: flex-end;
    padding: 10px 14px;
  }
}

/* Print Stylesheet */
@media print {
  /* Hide all dashboard/customer navigation and interactive buttons */
  #dd-sidebar,
  #dd-header,
  #dd-backdrop,
  .customer-legal-header,
  .legal-actions-group,
  .sidebar-footer,
  .dinedash-platform-footer,
  .fab,
  .btn-legal-action,
  nav,
  footer,
  button {
    display: none !important;
  }

  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  #dd-main,
  #dd-content,
  .legal-page-wrapper,
  .legal-body-card {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .legal-header-bar {
    border-bottom: 2px solid #000000 !important;
    margin-bottom: 16px !important;
  }

  .legal-section {
    page-break-inside: avoid;
    border-bottom: 1px solid #cccccc !important;
  }

  .legal-doc-meta-card {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
  }

  .legal-badge {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    background: none !important;
  }

  a {
    color: #000000 !important;
    text-decoration: underline !important;
  }
}
