/**
 * LDAP User Editor - Styles
 */

:root {
  --primary-color: #6200ee;
  --primary-dark: #3700b3;
  --success-color: #2e7d32;
  --error-color: #c62828;
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
}

.ldap-user-editor {
  font-family: 'Roboto', sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
  width: 100%;
  min-width: 0;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 2fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
}

.demo-panel {
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  overflow: auto;
  max-height: 800px;
  min-width: 0;
}

.demo-panel h2 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 16px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-panel h2 .material-icons {
  color: var(--primary-color);
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-width: 0;
}

.sidebar-header {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.sidebar-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.625rem 0.75rem 0.625rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box .material-icons {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  color: var(--text-secondary);
}

.user-tree {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  min-width: 0;
}

.tree-node {
  padding: 0.5rem;
  margin: 0.125rem 0;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.tree-node-toggle {
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-secondary);
  user-select: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.tree-node-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-list-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.user-list-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.user-list-header h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.user-list {
  flex: 1;
  overflow-y: auto;
}

.tree-node:hover {
  background: var(--bg-color);
}

.tree-node.active {
  background: rgba(98, 0, 238, 0.1);
  color: var(--primary-color);
  font-weight: 500;
}

.tree-node .material-icons {
  font-size: 1.25rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.tree-node.active .material-icons {
  color: var(--primary-color);
}

.tree-node-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tree-node-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node-email {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #999;
  text-align: center;
}

.empty-state .material-icons {
  font-size: 48px;
  color: #ddd;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 1rem;
  font-style: italic;
}

/* Editor */
.editor-container {
  width: 100%;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f0f0f0;
}

.editor-header .material-icons {
  font-size: 32px;
  color: #42a5f5;
}

.editor-title h3 {
  font-size: 18px;
  font-weight: 500;
  color: #333;
}

.editor-title .dn {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* Form */
.editor-form {
  padding: 0;
}

.form-section {
  margin-bottom: 2rem;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-label .required {
  color: var(--error-color);
}

.form-input,
.form-select {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(98, 0, 238, 0.1);
}

.form-input:disabled,
.form-select:disabled {
  background: var(--bg-color);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* Array fields */
.array-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.array-item {
  display: flex;
  gap: 0.5rem;
}

.array-item input,
.array-item select {
  flex: 1;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  background: var(--primary-color);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #ccc;
  color: #333;
}

.btn-secondary:hover:not(:disabled) {
  background: #aaa;
}

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

.btn-icon {
  padding: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon .material-icons {
  font-size: 1.25rem;
}

.editor-actions {
  display: flex;
  gap: 0.75rem;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background: #e8f5e9;
  color: var(--success-color);
}

.alert-error {
  background: #ffebee;
  color: var(--error-color);
}

.alert .material-icons {
  font-size: 20px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex; /* Show when active */
}

.modal-container {
  background: white;
  border-radius: 8px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.modal-close:hover {
  background-color: var(--bg-color);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
