/* Maya 2.0 ULTRA - Reusable Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error);
  color: var(--text-inverse);
  border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: #8a3a3a;
  border-color: #8a3a3a;
}

.btn-success {
  background: var(--success);
  color: var(--text-inverse);
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: #4a6a4a;
  border-color: #4a6a4a;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  height: 28px;
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  height: 44px;
}

.btn-icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-block {
  width: 100%;
}

/* Form elements */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.form-label .required {
  color: var(--error);
  margin-left: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

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

.form-textarea {
  min-height: 100px;
  resize: vertical;
  font-family: var(--font-sans);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7873' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 18px;
  padding-right: var(--space-10);
}

.form-help {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.form-error {
  display: block;
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: var(--space-1);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--error);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 3px var(--error-light);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check-input {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-input);
  border-radius: var(--radius-sm);
  appearance: none;
  position: relative;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.form-check-input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.form-check-input:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 6px;
  width: 4px;
  height: 8px;
  border: solid var(--text-inverse);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-check-input:focus {
  box-shadow: var(--focus-ring);
}

.form-check-input[type="radio"] {
  border-radius: 50%;
}

.form-check-input[type="radio"]:checked::after {
  width: 6px;
  height: 6px;
  top: 3px;
  left: 3px;
  border: none;
  background: var(--text-inverse);
  border-radius: 50%;
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  user-select: none;
}

/* Switch toggle */
.form-switch {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.form-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.form-switch-slider {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.form-switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.form-switch-input:checked + .form-switch-slider {
  background: var(--accent);
}

.form-switch-input:checked + .form-switch-slider::after {
  transform: translateX(18px);
}

.form-switch-input:focus + .form-switch-slider {
  box-shadow: var(--focus-ring);
}

.form-switch-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  user-select: none;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
  min-width: 0;
}

.card-header,
.card-body,
.card-footer {
  min-width: 0;
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Table */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-secondary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table td {
  color: var(--text-primary);
}

.table .cell-actions {
  display: flex;
  gap: var(--space-1);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  gap: var(--space-1);
}

.tab-btn {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-tertiary);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Accordion */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid var(--border);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card);
  border: none;
  text-align: left;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.accordion-header:hover {
  background: var(--bg-secondary);
}

.accordion-header .icon {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}

.accordion-header[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 var(--space-5);
  max-height: 0;
  overflow: hidden;
  transition: padding var(--transition), max-height var(--transition);
}

.accordion-content.open {
  padding: var(--space-4) var(--space-5);
  max-height: 500px;
}

/* Dropdown menu */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
  animation: dropdownIn var(--transition-fast) ease-out;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.dropdown-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-inverse);
  background: var(--text-primary);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: var(--z-tooltip);
  pointer-events: none;
}

.tooltip::after {
  content: "";
  position: absolute;
  bottom: calc(100% + var(--space-1));
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
}

.tooltip:hover::before,
.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Progress */
.progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition);
}

.progress-sm { height: 4px; }
.progress-lg { height: 10px; }

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  font-size: var(--text-sm);
}

.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-base); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--text-lg); }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* List group */
.list-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.list-group-item:last-child {
  border-bottom: none;
}

.list-group-item:hover {
  background: var(--bg-secondary);
}

.list-group-item.clickable {
  cursor: pointer;
}

/* Code block */
.code-block {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
}

.code-block pre {
  margin: 0;
  padding: var(--space-4);
  overflow: auto;
}

.code-block code {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
}

.code-inline {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

/* Utility classes */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }

.p-4 { padding: var(--space-4); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Notifications dropdown (header bell) */
.notifications-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: min(340px, calc(100vw - 24px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.18));
  z-index: 100;
}
.header-right { position: relative; }
.notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
}
.notification-item { padding: var(--space-3); border-bottom: 1px solid var(--border); cursor: pointer; }
.notification-item:last-child { border-bottom: 0; }
.notification-item.read { opacity: .55; }
.notification-title { font-weight: 600; font-size: var(--text-sm); }
.notification-body { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; word-break: break-word; }
