@import url('variables.css');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  scroll-behavior: smooth;
  overflow-x: hidden;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-bold);
}

/* Flex & Layout Utilities */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; min-width: 0; }
.gap-2xs { gap: var(--space-2xs); }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

/* Buttons (Trello Clean Design) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-xs);
}

.btn-lg {
  padding: 10px 20px;
  font-size: var(--font-size-md);
  border-radius: var(--radius-md);
}

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

.btn-secondary {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-overlay);
  border-color: var(--border-bold);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

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

.btn-ghost-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 104, 0.2);
}
.btn-ghost-danger:hover:not(:disabled) {
  background: var(--danger-subtle);
  border-color: var(--danger);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-icon:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

/* Discord Button */
.btn-discord {
  background-color: #5865F2;
  color: white;
  padding: 12px 24px;
  font-size: var(--font-size-md);
  font-weight: 600;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: 0 2px 6px rgba(88, 101, 242, 0.3);
}
.btn-discord:hover {
  background-color: #4752c4;
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.45);
  transform: translateY(-1px);
}
.btn-discord svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Form Inputs */
.form-group {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.form-input, input, textarea, select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.4;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, textarea:focus, select:focus, .form-input:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  padding: var(--space-md);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 520px;
  padding: var(--space-xl);
  transform: scale(0.96);
  transition: transform var(--transition-base);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-header h2, .modal-header h3 {
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.modal-close:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

/* Popover / Dropdown */
.popover {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-md);
  z-index: 1100;
  min-width: 220px;
  animation: popoverFadeIn var(--transition-fast);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-dropdown-container {
  position: relative;
}

.settings-dropdown {
  right: 0;
  top: calc(100% + 6px);
  width: 280px;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  padding: 16px;
  z-index: 1000;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.setting-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}


/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-default);
  transition: var(--transition-fast);
  border-radius: var(--radius-full);
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-subtle);
  transition: var(--transition-fast);
  border-radius: 50%;
}
input:checked + .toggle-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}
input:checked + .toggle-slider:before {
  transform: translateX(16px);
  background-color: #ffffff;
}

/* Progress Bars */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: var(--bg-surface-sunken);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background-color: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-base);
  user-select: none;
  color: var(--text-primary);
}
.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}
.checkmark {
  height: 18px;
  width: 18px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.custom-checkbox:hover input ~ .checkmark {
  border-color: var(--accent-primary);
}
.custom-checkbox input:checked ~ .checkmark {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}
.checkmark:after {
  content: "";
  display: none;
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.custom-checkbox input:checked ~ .checkmark:after {
  display: block;
}

/* Color Picker */
.color-picker {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}
.color-option {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  border: 2px solid transparent;
}
.color-option:hover {
  transform: scale(1.1);
}
.color-option.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent-primary);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: #ffffff;
  box-shadow: var(--shadow-modal);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: all var(--transition-base);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success {
  background: var(--success);
}
.toast-error {
  background: var(--danger);
}

/* Modal Stacking & Layering */
.modal-overlay.modal-stacked-behind {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.96);
  transition: all var(--transition-base);
}

/* Custom Dropdown (Trello-Style Dropdown Menu) */
.custom-dropdown-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.custom-dropdown-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.custom-dropdown-btn:hover {
  background: var(--bg-surface-raised);
  border-color: var(--border-bold);
}

.custom-dropdown-btn:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-primary-subtle);
  outline: none;
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  z-index: 1200;
  padding: 6px;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  animation: popoverFadeIn var(--transition-fast);
}

.custom-dropdown-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-dropdown-item {
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.custom-dropdown-item:hover {
  background: var(--bg-surface-raised);
}

.custom-dropdown-item.selected {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  font-weight: 600;
}

.custom-dropdown-item .item-check {
  margin-left: auto;
  opacity: 0;
}

.custom-dropdown-item.selected .item-check {
  opacity: 1;
}

/* Custom Hex & Palette Color Picker Modal */
.color-picker-dialog {
  max-width: 380px;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: var(--space-lg);
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent-primary);
}

.color-preview-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding: var(--space-sm);
  background: var(--bg-surface-sunken);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
}

.color-live-preview {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-bold);
  flex-shrink: 0;
}

.hex-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.hex-prefix {
  font-weight: 700;
  color: var(--text-subtle);
  font-size: var(--font-size-sm);
}

.hex-text-input {
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

