:root {
  /* Button Colors */
  --klx-btn-primary-bg: #3858e9;
  --klx-btn-primary-color: #fff;
  --klx-btn-primary-shadow: rgba(0, 0, 0, 0.1);

  --klx-btn-secondary-bg: transparent;
  --klx-btn-secondary-color: #2c3338;
  --klx-btn-secondary-border: rgba(0, 0, 0, 0.2);

  --klx-btn-hover-bg: rgba(255, 255, 255, 0.1);

  /* Button Border Radius */
  --klx-btn-border-radius: 6px;

  /* Cookie Banner Max Width */
  --klx-cookie-banner-max-width: 900px;
}

/* Base mobile-first styles */
.klx-cookie-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  color: #2c3338;
}

.klx-cookie-banner-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.klx-cookie-banner-content {
  position: relative;
  background: #fff;
  padding: 25px;
  border-radius: 12px;
  max-width: var(--klx-cookie-banner-max-width, 900px);
  width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  margin: 0 auto;
  max-height: 85vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.klx-cookie-banner h2 {
  margin: 0 0 15px;
  font-size: 24px;
  color: #1d2327;
  font-family: inherit;
  font-weight: 600;
  line-height: 1.3;
}

.klx-cookie-banner p {
  color: #2c3338;
  line-height: 1.6;
  font-size: 15px;
  font-family: inherit;
  margin-block-end: 0;
}

/* Settings View Specific Styles */
.klx-cookie-banner-settings .klx-cookie-banner-content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  height: 100%;
}

.klx-cookie-banner-settings .klx-cookie-categories {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 20px -25px 0;
  padding: 0 25px;
}

.klx-cookie-banner-settings h2 {
  color: #1d2327;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}

.klx-cookie-banner-settings p {
  color: #2c3338;
}

/* Category Styles */
.klx-cookie-category {
  margin-bottom: 15px;
  padding: 12px 0;
  background: transparent;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  cursor: default;
}

.klx-cookie-category:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.klx-cookie-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.klx-cookie-category-header span {
  font-weight: 600;
  font-size: 16px;
  color: #1d2327;
}

.klx-cookie-category .description {
  color: #666;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

/* Toggle Switch */
.klx-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.klx-switch input {
  opacity: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  z-index: 1;
}

.klx-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.15);
  transition: 0.3s;
  border-radius: 24px;
}

.klx-switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked+.klx-switch-slider {
  background-color: #3858e9;
}

input:disabled+.klx-switch-slider {
  opacity: 0.5;
  background-color: rgba(0, 0, 0, 0.1);
}

input:checked+.klx-switch-slider:before {
  transform: translateX(22px);
}

/* Button Styles - Common for both views */
.klx-cookie-banner-buttons {
  position: sticky;
  bottom: 0;
  background: inherit;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.klx-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--klx-btn-border-radius, 6px);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 14px;
  min-width: 100px;
  text-align: center;
}

/* Back button styles */
.klx-btn-back {
  background: var(--klx-btn-secondary-bg, transparent);
  color: var(--klx-btn-secondary-color, #2c3338);
  border: 1px solid var(--klx-btn-secondary-border, rgba(0, 0, 0, 0.2));
  display: inline-flex;
  align-items: center;
  margin-right: auto;
}

.klx-btn-back svg {
  margin-right: 4px;
}

/* Secondary buttons */
.klx-btn-deny {
  margin-left: auto;
  /* Push to right after back button */
}

/* Primary buttons */
.klx-btn-accept-all,
.klx-btn-save,
.klx-btn-override {
  background: var(--klx-btn-primary-bg, #3858e9);
  color: var(--klx-btn-primary-color, #fff);
  box-shadow: 0 2px 4px var(--klx-btn-primary-shadow, rgba(0, 0, 0, 0.1));
}

/* Footer Styles */
.klx-cookie-banner-footer {
  margin-top: 15px;
  padding-top: 15px;
  text-align: center;
  font-size: 13px;
  color: #666;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: sm;
}

.klx-cookie-banner-footer a {
  color: #3858e9;
  /* New primary color */
  text-decoration: none;
}

.klx-cookie-banner-footer a:hover {
  text-decoration: underline;
}

/* Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
  .klx-cookie-banner-initial .klx-cookie-banner-content {
    background: #111;
  }

  .klx-cookie-banner-initial h2 {
    color: #fff;
  }

  .klx-cookie-banner-initial p {
    color: #999;
  }

  .klx-btn-settings,
  .klx-btn-accept-necessary,
  .klx-btn-deny {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  .klx-btn-settings:hover,
  .klx-btn-accept-necessary:hover,
  .klx-btn-deny:hover {
    background: rgba(255, 255, 255, 0.15);
  }

  .klx-btn-back-icon {
    color: #fff;
  }

  .klx-btn-back-icon:hover {
    background: rgba(255, 255, 255, 0.15);
  }

  /* Settings view dark mode */
  .klx-cookie-banner-settings .klx-cookie-banner-content {
    background: #111;
    color: #fff;
  }

  .klx-cookie-banner-settings h2 {
    color: #fff;
    background: #111;
  }

  .klx-cookie-banner-settings p {
    color: #999;
  }

  .klx-cookie-category {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  .klx-cookie-category-header span {
    color: #fff;
  }

  .klx-cookie-category .description {
    color: #999;
  }

  /* Button styles for dark mode */
  .klx-btn-settings,
  .klx-btn-accept-necessary,
  .klx-btn-deny,
  .klx-btn-back {
    color: var(--klx-btn-primary-color, #fff);
    border: 1px solid var(--klx-btn-secondary-border, rgba(255, 255, 255, 0.2));
  }

  .klx-btn-settings:hover,
  .klx-btn-accept-necessary:hover,
  .klx-btn-deny:hover,
  .klx-btn-back:hover {
    background: var(--klx-btn-hover-bg, rgba(255, 255, 255, 0.1));
  }

  /* Footer styles for dark mode */
  .klx-cookie-banner-footer {
    color: #999;
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  /* Mobile specific dark mode adjustments */
  @media (max-width: 800px) {
    .klx-cookie-banner-settings .klx-cookie-banner-buttons {
      background: #111;
      border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
  }
}

/* Mobile styles */
@media (max-width: 800px) {
  .klx-cookie-banner {
    align-items: flex-end;
  }

  .klx-cookie-banner-content {
    padding: 20px;
    border-radius: 12px 12px 0 0;
    margin: 0;
    width: 100%;
    max-height: 85vh;
  }

  .klx-cookie-banner-settings .klx-cookie-categories {
    margin: 15px -20px 0;
    padding: 0 20px;
  }

  .klx-cookie-category {
    padding: 10px 0;
  }

  .klx-cookie-category-header span {
    font-size: 15px;
  }

  .klx-cookie-category .description {
    font-size: 13px;
  }

  /* Ensure proper safe area handling */
  .klx-cookie-banner-content {
    padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 20px);
  }
}

/* Very small screens */
@media (max-width: 800px) {
  .klx-cookie-banner-content {
    padding: 15px;
  }

  .klx-cookie-banner-settings .klx-cookie-categories {
    margin: 15px -15px 0;
    padding: 0 15px;
  }

  .klx-cookie-banner-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .klx-btn {
    width: 100%;
    justify-content: center;
  }

  .klx-btn-back,
  .klx-btn-deny {
    margin: 0;
    /* Remove auto margins on mobile */
  }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  .klx-cookie-banner {
    align-items: center;
    /* Center in landscape */
  }

  .klx-cookie-banner-content {
    max-height: 95vh;
    border-radius: 12px;
    /* Restore all rounded corners */
    margin: 10px;
  }

  .klx-cookie-banner-settings h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .klx-cookie-banner-settings p {
    font-size: 13px;
    margin-bottom: 15px;
  }

  .klx-cookie-category {
    padding: 10px 0;
    margin-bottom: 10px;
  }

  .klx-cookie-banner-settings .klx-cookie-banner-buttons {
    margin-top: 15px;
    padding-top: 15px;
  }
}

/* Ensure content is scrollable on all devices */
.klx-cookie-banner-settings .klx-cookie-categories {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS */
}

/* Handle very tall content on mobile */
@media (max-height: 700px) {
  .klx-cookie-banner-content {
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* Cookie Settings Link */
.klx-cookie-settings-link {
  text-align: center;
  padding: 10px 0;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.klx-cookie-settings-link a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.klx-cookie-settings-link a:hover {
  color: inherit;
  text-decoration: underline;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .klx-cookie-settings-link a {
    color: inherit;
  }

  .klx-cookie-settings-link a:hover {
    color: inherit;
  }
}