/**
 * FITREP Evaluator - Legal Hub Styles
 * Styles for legal document modals, clickwrap consent, and footer legal links
 */

/* ============================================================================
   Legal Document Modal - Generic Styling
   ============================================================================ */

.legal-document-modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.legal-document-modal.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

.legal-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.legal-modal-content {
  position: relative;
  z-index: 10001;
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  max-height: 85vh;
  width: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
}

.legal-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #ffffff;
}

.legal-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

.legal-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
}

.legal-modal-close:hover {
  background: #f0f0f0;
  color: #000;
}

.legal-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
  color: #1a1a1a;
  background: #ffffff;
}

/* Format markdown content inside legal modals */
.legal-modal-body h1,
.legal-modal-body h2,
.legal-modal-body h3 {
  margin: 20px 0 12px 0;
  font-weight: 600;
  color: #1a1a1a;
}

.legal-modal-body h1 { font-size: 20px; }
.legal-modal-body h2 { font-size: 18px; }
.legal-modal-body h3 { font-size: 16px; }

.legal-modal-body p {
  margin: 12px 0;
}

.legal-modal-body ul,
.legal-modal-body ol {
  margin: 12px 0;
  padding-left: 24px;
}

.legal-modal-body li {
  margin: 6px 0;
}

.legal-modal-body code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

.legal-modal-body strong {
  font-weight: 600;
  color: #000;
}

.legal-modal-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
}

.legal-modal-body table th,
.legal-modal-body table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

.legal-modal-body table th {
  background: #f9f9f9;
  font-weight: 600;
}

.legal-modal-footer {
  padding: 16px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  background: #f9f9f9;
}

/* ============================================================================
   Terms of Service Clickwrap Modal
   ============================================================================ */

.tos-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tos-modal {
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.tos-modal-content {
  padding: 32px;
  color: #1a1a1a;
}

.tos-modal-title {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}

.tos-modal-body {
  font-size: 13px;
  line-height: 1.6;
  color: #333;
  margin-bottom: 16px;
}

.tos-modal-body p {
  margin: 8px 0;
}

.tos-modal-body ul {
  margin: 8px 0;
  padding-left: 20px;
}

.tos-summary {
  /* Styled inline in the HTML template */
}

.tos-checkbox-group {
  /* Styled inline in the HTML template */
}

.tos-acceptance-checkbox {
  accent-color: #1976d2;
}

.tos-acceptance-checkbox:focus {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

.tos-button-group {
  /* Styled inline in the HTML template */
}

/* Button styling */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: #1976d2;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: #1565c0;
}

.btn-primary:disabled {
  background: #bdbdbd;
  cursor: not-allowed;
}

.btn-primary:focus {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

/* ============================================================================
   Footer Legal Links
   ============================================================================ */

.legal-hub-footer {
  display: block;
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: #000000 !important;
}

.legal-link {
  transition: opacity 0.2s ease;
  white-space: nowrap;
  color: #000000 !important;
  text-decoration: underline;
  cursor: pointer;
  margin: 0 2px;
}

.legal-link:hover {
  opacity: 0.7;
}

.legal-link:focus {
  outline: 2px solid #000000;
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  .legal-hub-footer {
    color: #e0e0e0;
  }

  .legal-link {
    color: #e0e0e0;
  }

  .legal-link:focus {
    outline-color: #e0e0e0;
  }
}

.legal-link-inline {
  color: #1976d2;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s ease;
}

.legal-link-inline:hover {
  color: #1565c0;
}

.legal-link-inline:focus {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

/* ============================================================================
   Hidden Content (when modals are blocking)
   ============================================================================ */

.tos-app-hidden {
  display: none !important;
}

.legal-app-hidden {
  display: none !important;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
  .legal-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .tos-modal {
    width: 95%;
    max-height: 90vh;
  }

  .tos-modal-content {
    padding: 20px;
  }

  .legal-modal-header {
    padding: 16px;
  }

  .legal-modal-body {
    padding: 16px;
  }

  .legal-modal-footer {
    padding: 12px;
  }

  .tos-modal-title {
    font-size: 18px;
  }

  .legal-modal-title {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .legal-modal-content,
  .tos-modal {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .tos-modal-content {
    padding: 16px;
  }

  .legal-hub-footer {
    flex-wrap: wrap;
    font-size: 11px;
  }
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
  .legal-modal-overlay,
  .tos-modal-overlay,
  .legal-modal-close {
    display: none !important;
  }

  .legal-modal-content,
  .tos-modal {
    box-shadow: none;
    max-height: none;
    overflow: visible;
  }

  .legal-modal-body,
  .tos-modal-body {
    overflow: visible;
  }
}

/* ============================================================================
   Dark Mode Support (if theme toggle is used)
   ============================================================================ */

/* Light mode (default) */
.legal-modal-content,
.legal-modal-body,
.legal-modal-header,
.legal-modal-footer {
  background: #ffffff;
  color: #1a1a1a;
}

.legal-modal-body h1,
.legal-modal-body h2,
.legal-modal-body h3,
.legal-modal-body strong {
  color: #1a1a1a;
}

.legal-modal-body code {
  background: #f4f4f4;
  color: #d73a49;
}

.legal-modal-body table th {
  background: #f9f9f9;
  color: #1a1a1a;
}

.legal-modal-body table th,
.legal-modal-body table td {
  border-color: #ddd;
  color: #1a1a1a;
}

.legal-modal-header,
.legal-modal-footer {
  border-color: #e0e0e0;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .legal-modal-content {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .legal-modal-header,
  .legal-modal-footer {
    background: #2d2d2d;
    border-color: #444;
  }

  .legal-modal-body {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .legal-modal-title,
  .legal-modal-body h1,
  .legal-modal-body h2,
  .legal-modal-body h3,
  .legal-modal-body strong {
    color: #ffffff;
  }

  .legal-modal-close {
    color: #aaa;
  }

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

  .legal-modal-body code {
    background: #1e1e1e;
    color: #7ec699;
    border: 1px solid #444;
  }

  .legal-modal-body table th {
    background: #3a3a3a;
    color: #e0e0e0;
  }

  .legal-modal-body table th,
  .legal-modal-body table td {
    border-color: #444;
    color: #e0e0e0;
  }

  .tos-modal {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .tos-modal-title {
    color: #ffffff;
  }
}
