/**
 * LDAP Tree Viewer - Material Design Styles
 */

/* CSS Variables - Material Design tokens */
:root {
  --mdc-theme-primary: #6200ee;
  --mdc-theme-primary-variant: #3700b3;
  --mdc-theme-on-primary: #ffffff;
  --mdc-theme-surface: #ffffff;
  --mdc-theme-on-surface: rgba(0, 0, 0, 0.87);
  --mdc-theme-background: #fafafa;
  --mdc-theme-error: #b00020;

  /* Tree specific */
  --tree-node-height: 40px;
  --tree-indent: 24px;
  --tree-icon-size: 24px;
  --tree-toggle-size: 40px;
  --tree-border-radius: 4px;
  --tree-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme */
.ldap-tree-viewer--dark {
  --mdc-theme-surface: #121212;
  --mdc-theme-on-surface: rgba(255, 255, 255, 0.87);
  --mdc-theme-background: #1e1e1e;
}

/* Container */
.ldap-tree-viewer-container {
  font-family:
    'Roboto',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--mdc-theme-on-surface);
}

.ldap-tree-viewer {
  background: var(--mdc-theme-surface);
  border-radius: var(--tree-border-radius);
  padding: 8px;
  min-height: 200px;
}

/* Tree root */
.mdc-tree-root {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Tree node */
.mdc-tree-node {
  list-style: none;
  margin: 0;
  padding: 0;
  user-select: none;
}

.mdc-tree-node__content {
  display: flex;
  align-items: center;
  min-height: var(--tree-node-height);
  padding: 0 8px;
  cursor: pointer;
  border-radius: var(--tree-border-radius);
  transition: background-color var(--tree-transition);
  position: relative;
}

.mdc-tree-node__content:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.ldap-tree-viewer--dark .mdc-tree-node__content:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.mdc-tree-node--selected > .mdc-tree-node__content {
  background-color: rgba(98, 0, 238, 0.12);
}

.ldap-tree-viewer--dark .mdc-tree-node--selected > .mdc-tree-node__content {
  background-color: rgba(187, 134, 252, 0.24);
}

/* Toggle button */
.mdc-tree-node__toggle {
  width: var(--tree-toggle-size);
  height: var(--tree-toggle-size);
  padding: 8px;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--tree-transition);
  flex-shrink: 0;
}

.mdc-tree-node__toggle:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.ldap-tree-viewer--dark .mdc-tree-node__toggle:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.mdc-tree-node__toggle .material-icons {
  font-size: var(--tree-icon-size);
  color: var(--mdc-theme-on-surface);
  transition: transform var(--tree-transition);
}

.mdc-tree-node--expanded
  > .mdc-tree-node__content
  .mdc-tree-node__toggle
  .material-icons {
  transform: rotate(0deg);
}

/* Spacer for nodes without children */
.mdc-tree-node__spacer {
  width: var(--tree-toggle-size);
  height: var(--tree-toggle-size);
  flex-shrink: 0;
}

/* Icon */
.mdc-tree-node__icon {
  width: var(--tree-icon-size);
  height: var(--tree-icon-size);
  font-size: var(--tree-icon-size);
  margin-right: 12px;
  flex-shrink: 0;
  color: rgba(0, 0, 0, 0.54);
}

.ldap-tree-viewer--dark .mdc-tree-node__icon {
  color: rgba(255, 255, 255, 0.7);
}

.mdc-tree-node--organization > .mdc-tree-node__content .mdc-tree-node__icon {
  color: #ffa726;
}

.mdc-tree-node--user > .mdc-tree-node__content .mdc-tree-node__icon {
  color: #42a5f5;
}

.mdc-tree-node--group > .mdc-tree-node__content .mdc-tree-node__icon {
  color: #66bb6a;
}

/* Label */
.mdc-tree-node__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Children */
.mdc-tree-node__children {
  list-style: none;
  margin: 0;
  padding-left: var(--tree-indent);
  overflow: hidden;
}

/* Loading spinner */
.mdc-circular-progress {
  display: inline-block;
  width: 48px;
  height: 48px;
  margin-left: auto;
}

.mdc-circular-progress--small {
  width: 20px;
  height: 20px;
  margin-left: 8px;
}

.mdc-circular-progress--indeterminate
  .mdc-circular-progress__determinate-container {
  display: none;
}

.mdc-circular-progress__indeterminate-container {
  animation: mdc-circular-progress-container-rotate 1568ms linear infinite;
}

@keyframes mdc-circular-progress-container-rotate {
  to {
    transform: rotate(360deg);
  }
}

.mdc-circular-progress__spinner-layer {
  animation: mdc-circular-progress-spinner-layer-rotate 5332ms
    cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes mdc-circular-progress-spinner-layer-rotate {
  12.5% {
    transform: rotate(135deg);
  }
  25% {
    transform: rotate(270deg);
  }
  37.5% {
    transform: rotate(405deg);
  }
  50% {
    transform: rotate(540deg);
  }
  62.5% {
    transform: rotate(675deg);
  }
  75% {
    transform: rotate(810deg);
  }
  87.5% {
    transform: rotate(945deg);
  }
  100% {
    transform: rotate(1080deg);
  }
}

.mdc-circular-progress__circle-clipper {
  display: inline-flex;
  position: relative;
  width: 50%;
  height: 100%;
  overflow: hidden;
}

.mdc-circular-progress__circle-clipper
  .mdc-circular-progress__indeterminate-circle-graphic {
  width: 200%;
}

.mdc-circular-progress__circle-left
  .mdc-circular-progress__indeterminate-circle-graphic {
  animation: mdc-circular-progress-left-spin 1333ms cubic-bezier(0.4, 0, 0.2, 1)
    infinite;
  transform-origin: right center;
}

@keyframes mdc-circular-progress-left-spin {
  from {
    transform: rotate(130deg);
  }
  50% {
    transform: rotate(-5deg);
  }
  to {
    transform: rotate(130deg);
  }
}

.mdc-circular-progress__circle-right
  .mdc-circular-progress__indeterminate-circle-graphic {
  animation: mdc-circular-progress-right-spin 1333ms
    cubic-bezier(0.4, 0, 0.2, 1) infinite;
  left: -100%;
  transform-origin: left center;
}

@keyframes mdc-circular-progress-right-spin {
  from {
    transform: rotate(-130deg);
  }
  50% {
    transform: rotate(5deg);
  }
  to {
    transform: rotate(-130deg);
  }
}

.mdc-circular-progress__gap-patch {
  position: absolute;
  top: 0;
  left: 47.5%;
  width: 5%;
  height: 100%;
  overflow: hidden;
}

.mdc-circular-progress__gap-patch
  .mdc-circular-progress__indeterminate-circle-graphic {
  width: 1000%;
  left: -450%;
}

.mdc-circular-progress__indeterminate-circle-graphic circle {
  fill: transparent;
  stroke: var(--mdc-theme-primary);
  stroke-linecap: square;
}

/* Loading state */
.mdc-tree-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 16px;
}

.mdc-tree-loading__text {
  color: var(--mdc-theme-on-surface);
  opacity: 0.6;
}

/* Error state */
.mdc-tree-error {
  display: flex;
  align-items: center;
  padding: 16px;
  background-color: rgba(176, 0, 32, 0.08);
  border-radius: var(--tree-border-radius);
  color: var(--mdc-theme-error);
  gap: 12px;
}

.mdc-tree-error__icon {
  font-size: 24px;
  flex-shrink: 0;
}

.mdc-tree-error__message {
  flex: 1;
}

/* Material icons fallback */
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}
