/* Conditional Access Component - Complete CSS */

/* Main container */
.ca-interface {
  margin: 2rem 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

.ca-container {
  display: flex;
  max-width: 1000px;
  margin: 0 auto;
  border: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  background-color: var(--md-default-bg-color, white);
}

/* Left column navigation */
.ca-left-column {
  width: 280px;
  background-color: var(--md-default-fg-color--lightest, #f3f2f1);
  border-right: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
}

.ca-section {
  padding: 0.75rem 1.25rem;
  border-left: 3px solid transparent;
  position: relative;
  cursor: pointer;
}

.ca-section:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.ca-section.ca-active {
  background-color: rgba(0, 0, 0, 0.05);
  border-left: 3px solid var(--md-primary-fg-color, #0078d4);
  font-weight: 500;
}

.ca-divider {
  height: 2px;
  background-color: rgba(0, 0, 0, 0.15);
  margin: 12px 8px;
  border-radius: 1px;
}

.ca-header {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  word-wrap: break-word;
  line-height: 1.3;
}

.ca-subtext {
  font-size: 0.75rem;
  color: var(--md-default-fg-color--light, #605e5c);
}

/* Right column content */
.ca-right-column {
  flex: 1;
  padding: 1.5rem;
  overflow-x: hidden;
}

.ca-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--md-default-fg-color, #323130);
}

/* Cards */
.ca-card {
  background-color: var(--md-default-bg-color, white);
  border: 1px solid var(--md-default-fg-color--lightest, #edebe9);
  border-radius: 4px;
  padding: .5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  position: relative;
}

/* More aggressive fix for header overlap */
.ca-card .ca-header {
  padding-right: 100px; /* Even more space for both "None selected" and "Show" */
  margin-bottom: 0.75rem;
  word-wrap: break-word;
  line-height: 1.3;
  max-width: 100%;
}

/* Options */
.ca-option {
  display: flex;
  align-items: flex-start;
  padding: 0.5rem 0;
  position: relative;
}

.ca-option span:not(.ca-checkbox):not(.ca-radio) {
  line-height: 1.4;
  padding-right: 40px; /* Space for the 'Required' label */
}

/* Radio buttons and checkboxes */
.ca-radio, .ca-checkbox {
  display: inline-block;
  min-width: 16px;
  height: 16px;
  border: 1px solid var(--md-default-fg-color--light, #605e5c);
  margin-right: 0.75rem;
  margin-top: 2px;
  flex-shrink: 0;
  position: relative;
}

.ca-radio {
  border-radius: 50%;
}

.ca-radio.ca-checked:after, .ca-checkbox.ca-checked:after {
  content: "";
  position: absolute;
  display: block;
}

.ca-radio.ca-checked:after {
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--md-primary-fg-color, #0078d4);
}

.ca-checkbox.ca-checked:after {
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid var(--md-primary-fg-color, #0078d4);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Nested options */
.ca-nested {
  margin-left: 2rem;
  margin-top: 0rem;
}

.ca-hidden {
  display: none;
}

/* Buttons */
.ca-button {
  background-color: var(--md-primary-fg-color, #0078d4);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 2px;
  font-weight: 500;
  margin-top: 1rem;
  cursor: default;
}

/* Content section visibility */
.ca-content-section {
  display: none;
}

.ca-content-section.ca-active {
  display: block;
}

/* Collapsed cards */
.ca-card.ca-collapsed {
  position: relative;
  padding-bottom: 0.5rem;
}

.ca-card.ca-collapsed .ca-option {
  display: none;
}

.ca-card.ca-collapsed .ca-nested {
  display: none;
}

.ca-card.ca-collapsed .ca-header {
  margin-bottom: 0;
}

.ca-card.ca-collapsed:after {
  content: "None selected";
  position: absolute;
  right: 3.5rem;
  top: 1rem;
  font-size: 0.65rem; /* Smaller font */
  color: var(--md-default-fg-color--light, #605e5c);
  white-space: nowrap;
  z-index: 1;
}

.ca-card-toggle {
  position: absolute;
  top: .5rem;
  right: 1rem;
  cursor: pointer;
  color: var(--md-primary-fg-color, #0078d4);
  font-size: 0.7rem; /* Smaller font */
  font-weight: 500;
  background-color: transparent;
  border: none;
  padding: 0;
  z-index: 2;
  width: 2rem; /* Smaller fixed width */
  text-align: right;
}

/* Highlighting */
.ca-checkbox.ca-highlight, .ca-radio.ca-highlight {
  border-color: var(--md-accent-fg-color, #ff5252);
  border-width: 2px;
  box-shadow: 0 0 0 1px rgba(255, 82, 82, 0.2);
}

.ca-checkbox.ca-highlight:after, .ca-radio.ca-highlight:after {
  border-color: var(--md-accent-fg-color, #ff5252);
}

.ca-radio.ca-highlight:after {
  background-color: var(--md-accent-fg-color, #ff5252);
}

.ca-highlight-text {
  font-weight: 600;
  color: var(--md-accent-fg-color, #ff5252);
}

.ca-option.ca-highlight-row {
  border-left: 3px solid var(--md-accent-fg-color, #ff5252);
  padding-left: 6px;
  margin-left: -9px;
  background-color: rgba(255, 82, 82, 0.05);
}

.ca-option.ca-highlight-row:after {
  content: "Required";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--md-accent-fg-color, #ff5252);
  background-color: rgba(255, 82, 82, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Responsive design */
@media screen and (max-width: 768px) {
  .ca-container {
    flex-direction: column;
  }
  
  .ca-left-column {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
  }
}

@media screen and (max-width: 480px) {
  .ca-right-column {
    padding: 1rem;
  }
  
  .ca-card {
    padding: 0.75rem;
  }
  
  .ca-card .ca-header {
    padding-right: 75px;
    font-size: 0.9rem;
  }
  
  .ca-card.ca-collapsed:after {
    right: 3rem;
    font-size: 0.7rem;
  }
  
  .ca-option.ca-highlight-row:after {
    top: auto;
    right: auto;
    transform: none;
    position: relative;
    display: inline-block;
    margin-top: 5px;
    margin-left: 26px;
  }
  
  .ca-option span:not(.ca-checkbox):not(.ca-radio) {
    padding-right: 0;
  }
}

/* Dark mode compatibility */
@media (prefers-color-scheme: dark) {
  .ca-divider {
    background-color: rgba(255, 255, 255, 0.15);
  }
}

/* Disclaimer styling */
.ca-disclaimer {
  background-color: rgba(0, 120, 212, 0.1);
  border-left: 3px solid var(--md-primary-fg-color, #0078d4);
  padding: 0.5rem 1rem;
  margin-bottom: 0rem;
  margin-left: 1px;
  font-size: 0.85rem;
  color: var(--md-default-fg-color, #323130);
  border-radius: 2px;
}

.ca-disclaimer p {
  margin: 0.25rem 0;
}

.ca-disclaimer strong {
  color: var(--md-primary-fg-color, #0078d4);
}

/* Adjust check position for highlighted elements */
.ca-checkbox.ca-highlight.ca-checked:after {
  top: 1px;
  left: 4px;
}

.ca-radio.ca-highlight.ca-checked:after {
  top: 2px;
  left: 2px;
}

/* Indicator for sections with configurations */
.ca-section.ca-configured {
  background-color: rgba(0, 120, 212, 0.05);
  border-left-color: rgba(0, 120, 212, 0.5);
}

.ca-section.ca-configured:not(.ca-active) .ca-header {
  color: var(--md-primary-fg-color, #0078d4);
}

/* Make active state clearer */
.ca-section.ca-active {
  background-color: rgba(0, 120, 212, 0.1);
  border-left: 3px solid var(--md-primary-fg-color, #0078d4);
  font-weight: 500;
}

/* Ensure active state takes precedence */
.ca-section.ca-configured.ca-active {
  background-color: rgba(0, 120, 212, 0.15);
  border-left: 3px solid var(--md-primary-fg-color, #0078d4);
}

/* Add an indicator for active+configured sections */
.ca-section.ca-configured.ca-active::after {
  content: "●";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--md-primary-fg-color, #0078d4);
  font-size: 10px;
}

/* App styling */
.ca-app-option {
  padding-left: 15px;
}

.ca-app-icon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  display: inline-block;
}

.ca-apps {
  margin-left: 2.5rem;
}

/* Make active state clearer */
.ca-section.ca-active {
  background-color: rgba(0, 120, 212, 0.1);
  border-left: 3px solid var(--md-primary-fg-color, #0078d4);
  font-weight: 500;
}

/* Ensure active state takes precedence */
.ca-section.ca-configured.ca-active {
  background-color: rgba(0, 120, 212, 0.15);
  border-left: 3px solid var(--md-primary-fg-color, #0078d4);
}

/* Indicator for sections with configurations */
.ca-section.ca-configured {
  background-color: rgba(0, 120, 212, 0.05);
  border-left-color: rgba(0, 120, 212, 0.5);
}

.ca-section.ca-configured:not(.ca-active) .ca-header {
  color: var(--md-primary-fg-color, #0078d4);
}

/* Adjust check position for highlighted elements */
.ca-checkbox.ca-highlight.ca-checked:after {
  top: 1px;
  left: 4px;
}

.ca-radio.ca-highlight.ca-checked:after {
  top: 2px;
  left: 2px;
}

/* Make radio and checkbox controls not directly interactive */
.ca-radio, .ca-checkbox {
  pointer-events: none;
}

.ca-option {
  position: relative;
  cursor: pointer;
  pointer-events: none;
}

.ca-control-wrapper {
  display: inline-block;
  position: relative;
}

.ca-control-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
}

.ca-label {
  cursor: pointer;
}

/* Only show "None selected" for empty cards */
.ca-card.ca-empty:after {
  content: "None selected";
  position: absolute;
  right: 3.5rem;
  top: 1rem;
  font-size: 0.65rem;
  color: var(--md-default-fg-color--light, #605e5c);
  white-space: nowrap;
  z-index: 1;
}

/* Remove the generic "None selected" from all collapsed cards */
.ca-card.ca-collapsed:after {
  content: none !important;
}

/* Add it back, but only for cards that actually have no selections */
.ca-card.ca-collapsed:not(:has(.ca-checked)):after {
  content: "None selected" !important;
  position: absolute;
  right: 3.5rem;
  top: .5rem;
  font-size: 0.65rem;
  color: var(--md-default-fg-color--light, #605e5c);
  white-space: nowrap;
  z-index: 1;
}

.ca-app-label {
  font-size: 0.5rem;
}

/* Reset and force flexbox layout */
.ca-container {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  min-height: 500px !important;
  width: 100% !important;
  max-width: 1200px !important;
}

/* Fix left column dimensions */
.ca-left-column {
  width: 280px !important;
  min-width: 280px !important;
  flex: 0 0 280px !important;
  overflow-y: auto !important;
  position: relative !important;
  z-index: 10 !important;
}

/* Fix right column to take remaining space */
.ca-right-column {
  flex: 1 1 auto !important;
  min-width: 0 !important; /* Critical for flexbox behavior */
  width: auto !important;
  overflow-x: hidden !important;
  position: relative !important;
  z-index: 5 !important;
}

/* Make interface container a proper block */
.ca-interface {
  display: block !important;
  width: 100% !important;
}

/* Fix all flex items to not wrap */
.ca-container > * {
  flex-shrink: 0 !important;
}

/* Reset the container to normal display */
.ca-container {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  min-height: 500px;
  width: 100%;
  position: static; /* Ensure no positioning side effects */
  z-index: auto; /* Reset z-index */
}

/* Fix left column */
.ca-left-column {
  width: 280px;
  min-width: 280px;
  flex: 0 0 280px;
  position: static; /* No special positioning */
}

/* Fix right column */
.ca-right-column {
  flex: 1;
  min-width: 0; /* Critical for flexbox behavior */
  overflow-x: hidden;
  position: static; /* No special positioning */
}

/* Reset the interface container */
.ca-interface {
  display: block;
  position: static; /* Important - ensures no fixed/sticky behavior */
  z-index: auto;
  overflow: visible;
}

/* Remove any positioning from parent elements */
conditional-access {
  position: static !important;
  z-index: auto !important;
}

/* Ensure the component doesn't escape its container */
conditional-access, .ca-interface {
  contain: layout; /* Modern browsers only */
}