/* =============================================================================
   Consent Manager — Privacy Center Stylesheet
   ============================================================================= */

/* --- CSS Custom Properties (overridden by tenant branding via JS) --- */
:root {
  --cm-primary:      #1a56db;
  --cm-primary-dark: #1345b7;
  --cm-primary-light:#eff6ff;
  --cm-success:      #16a34a;
  --cm-danger:       #dc2626;
  --cm-warning:      #d97706;
  --cm-gray-50:      #f9fafb;
  --cm-gray-100:     #f3f4f6;
  --cm-gray-200:     #e5e7eb;
  --cm-gray-400:     #9ca3af;
  --cm-gray-500:     #6b7280;
  --cm-gray-700:     #374151;
  --cm-gray-900:     #111827;
  --cm-font:         'Inter', system-ui, -apple-system, sans-serif;
  --cm-radius:       10px;
  --cm-shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --cm-shadow-lg:    0 10px 25px rgba(0,0,0,.1);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--cm-font);
  color: var(--cm-gray-900);
  background: var(--cm-gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cm-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* --- Layout --- */
.cm-layout { min-height: 100vh; display: flex; flex-direction: column; }

.cm-header {
  background: #fff;
  border-bottom: 1px solid var(--cm-gray-200);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--cm-shadow);
}

.cm-header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--cm-gray-900);
}
.cm-header__logo img { height: 32px; width: auto; }
.cm-header__badge {
  font-size: 11px;
  background: var(--cm-primary-light);
  color: var(--cm-primary);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.cm-header__nav { display: flex; gap: 4px; align-items: center; }
.cm-nav-link {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--cm-gray-700);
  transition: background .15s;
}
.cm-nav-link:hover { background: var(--cm-gray-100); text-decoration: none; }
.cm-nav-link.active {
  background: var(--cm-primary-light);
  color: var(--cm-primary);
}

.cm-main { flex: 1; max-width: 860px; width: 100%; margin: 0 auto; padding: 32px 24px; }

.cm-footer {
  background: #fff;
  border-top: 1px solid var(--cm-gray-200);
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--cm-gray-400);
}
.cm-footer a { color: var(--cm-gray-500); }

/* --- Page Title --- */
.cm-page-header { margin-bottom: 28px; }
.cm-page-header h1 { font-size: 24px; font-weight: 700; color: var(--cm-gray-900); }
.cm-page-header p { font-size: 15px; color: var(--cm-gray-500); margin-top: 4px; }

/* --- Cards --- */
.cm-card {
  background: #fff;
  border: 1px solid var(--cm-gray-200);
  border-radius: var(--cm-radius);
  padding: 24px;
  box-shadow: var(--cm-shadow);
  margin-bottom: 20px;
}
.cm-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--cm-gray-100);
}
.cm-card__title { font-size: 16px; font-weight: 600; }
.cm-card__subtitle { font-size: 13px; color: var(--cm-gray-500); margin-top: 2px; }

/* --- Badges / Status --- */
.cm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.cm-badge--green  { background: #dcfce7; color: #166534; }
.cm-badge--red    { background: #fee2e2; color: #991b1b; }
.cm-badge--yellow { background: #fef9c3; color: #92400e; }
.cm-badge--blue   { background: var(--cm-primary-light); color: var(--cm-primary); }
.cm-badge--gray   { background: var(--cm-gray-100); color: var(--cm-gray-500); }

/* --- Toggles (Purpose switches) --- */
.cm-purpose-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--cm-gray-100);
}
.cm-purpose-item:last-child { border-bottom: none; }
.cm-purpose-info { flex: 1; }
.cm-purpose-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.cm-purpose-desc { font-size: 13px; color: var(--cm-gray-500); margin-bottom: 6px; }
.cm-purpose-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-meta-tag {
  font-size: 11px;
  background: var(--cm-gray-100);
  color: var(--cm-gray-700);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Toggle switch */
.cm-switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.cm-switch input { opacity: 0; width: 0; height: 0; }
.cm-switch__slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--cm-gray-200);
  border-radius: 28px;
  transition: .3s;
}
.cm-switch__slider:before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: .3s;
}
.cm-switch input:checked + .cm-switch__slider { background: var(--cm-primary); }
.cm-switch input:checked + .cm-switch__slider:before { transform: translateX(22px); }
.cm-switch input:disabled + .cm-switch__slider { cursor: not-allowed; opacity: .5; }

/* --- Buttons --- */
.cm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  line-height: 1;
  text-decoration: none;
}
.cm-btn:disabled { opacity: .5; cursor: not-allowed; }
.cm-btn--primary { background: var(--cm-primary); color: #fff; }
.cm-btn--primary:hover:not(:disabled) { background: var(--cm-primary-dark); text-decoration: none; }
.cm-btn--secondary { background: var(--cm-gray-100); color: var(--cm-gray-700); border: 1px solid var(--cm-gray-200); }
.cm-btn--secondary:hover:not(:disabled) { background: var(--cm-gray-200); text-decoration: none; }
.cm-btn--danger { background: var(--cm-danger); color: #fff; }
.cm-btn--danger:hover:not(:disabled) { background: #b91c1c; text-decoration: none; }
.cm-btn--ghost { background: transparent; color: var(--cm-gray-500); }
.cm-btn--ghost:hover:not(:disabled) { color: var(--cm-gray-900); background: var(--cm-gray-100); text-decoration: none; }
.cm-btn--full { width: 100%; justify-content: center; }
.cm-btn--sm { padding: 7px 14px; font-size: 13px; }

/* --- Forms --- */
.cm-form-group { margin-bottom: 18px; }
.cm-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--cm-gray-700); }
.cm-input, .cm-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cm-gray-200);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--cm-gray-900);
  background: #fff;
  transition: border-color .2s;
}
.cm-input:focus, .cm-textarea:focus {
  outline: none;
  border-color: var(--cm-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}
.cm-textarea { resize: vertical; min-height: 100px; }

/* --- Timeline (History) --- */
.cm-timeline { list-style: none; position: relative; }
.cm-timeline::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--cm-gray-200);
}
.cm-timeline__item { display: flex; gap: 16px; padding: 0 0 20px; position: relative; }
.cm-timeline__dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  z-index: 1;
  border: 3px solid #fff;
  box-shadow: var(--cm-shadow);
}
.cm-timeline__dot--green  { background: #dcfce7; }
.cm-timeline__dot--red    { background: #fee2e2; }
.cm-timeline__dot--blue   { background: var(--cm-primary-light); }
.cm-timeline__dot--gray   { background: var(--cm-gray-100); }
.cm-timeline__content { flex: 1; padding-top: 6px; }
.cm-timeline__title { font-size: 14px; font-weight: 600; }
.cm-timeline__meta  { font-size: 12px; color: var(--cm-gray-400); margin-top: 2px; }
.cm-timeline__detail { font-size: 13px; color: var(--cm-gray-500); margin-top: 4px; }

/* --- Alerts --- */
.cm-alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.cm-alert--info    { background: var(--cm-primary-light); color: #1e40af; border: 1px solid #bfdbfe; }
.cm-alert--success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.cm-alert--warning { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.cm-alert--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.cm-alert__icon    { font-size: 18px; flex-shrink: 0; line-height: 1.3; }

/* --- Loading --- */
.cm-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  flex-direction: column;
  gap: 12px;
  color: var(--cm-gray-400);
}
.cm-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--cm-gray-200);
  border-top-color: var(--cm-primary);
  border-radius: 50%;
  animation: cm-spin .8s linear infinite;
}
@keyframes cm-spin { to { transform: rotate(360deg); } }

/* --- Modal --- */
.cm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cm-modal {
  background: #fff;
  border-radius: var(--cm-radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--cm-shadow-lg);
}
.cm-modal__header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--cm-gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cm-modal__title { font-size: 18px; font-weight: 700; }
.cm-modal__body  { padding: 20px 24px; }
.cm-modal__footer { padding: 16px 24px; border-top: 1px solid var(--cm-gray-100); display: flex; gap: 8px; justify-content: flex-end; }
.cm-modal-close { background: none; border: none; cursor: pointer; padding: 4px; color: var(--cm-gray-400); font-size: 20px; line-height: 1; }

/* --- ISO badge --- */
.cm-iso-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--cm-gray-400);
  border: 1px solid var(--cm-gray-200);
  border-radius: 6px;
  padding: 4px 10px;
}
.cm-iso-badge strong { color: var(--cm-gray-700); }

/* --- Responsive --- */
@media (max-width: 640px) {
  .cm-main { padding: 20px 16px; }
  .cm-header { flex-wrap: wrap; }
  .cm-header__nav { width: 100%; overflow-x: auto; }
  .cm-card { padding: 16px; }
  .cm-page-header h1 { font-size: 20px; }
}
