/* Trade Add/Edit Modal Styles
 * Follows Dex Alpha premium design standard
 */

/* ========== Trade Modal Container ========== */
.trade-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: visible;
  opacity: 1;
}

.trade-modal .modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 1;
}

.trade-modal .modal-content {
  position: relative;
  z-index: 2;
  max-width: 600px;
  width: 90vw;
  background: var(--color-bg-card, #1a1a2e);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--color-border, #333);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.4),
    0 12px 24px rgba(0, 0, 0, 0.2);
}

.trade-modal .modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border, #333);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-bg-secondary, #141920);
  flex-shrink: 0;
}

.trade-modal .modal-header h3 {
  margin: 0;
  color: var(--color-text-primary, #fff);
  font-size: 1.125rem;
  font-weight: 600;
}

.trade-modal .modal-close {
  background: transparent;
  border: none;
  color: var(--color-text-secondary, #888);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: var(--radius-sm, 4px);
  transition: all 0.15s ease;
}

.trade-modal .modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary, #fff);
}

/* ========== Form Layout ========== */
.trade-modal .trade-form {
  padding: 1.25rem;
  flex: 1;
  overflow-y: auto;
}

.trade-modal .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4, 1rem);
}

.trade-modal .form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-4, 1rem);
}

.trade-modal .form-section {
  margin-top: var(--space-4, 1rem);
  padding-top: var(--space-4, 1rem);
  border-top: 1px solid var(--color-border, #333);
}

.trade-modal .form-section-title {
  margin: 0 0 var(--space-3, 0.75rem) 0;
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-secondary, #888);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ========== Form Fields ========== */
.trade-modal label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.trade-modal label > span {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-secondary, #888);
  font-weight: 500;
}

.trade-modal label > span .required {
  color: var(--color-error, #ef4444);
  margin-left: 2px;
}

.trade-modal .input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius, 8px);
  padding: 0.625rem 0.875rem;
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-primary, #fff);
  transition: all 0.15s ease;
  outline: none;
  width: 100%;
}

.trade-modal .input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-brand, #06b6d4);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 6, 182, 212), 0.15);
}

.trade-modal .input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.trade-modal .input::placeholder {
  color: var(--color-text-tertiary, #555);
}

/* ========== Input Wrapper with Action Button ========== */
.trade-modal .input-with-action {
  display: flex;
  gap: 0.5rem;
}

.trade-modal .input-with-action .input {
  flex: 1;
}

.trade-modal .input-action-btn {
  background: rgba(var(--brand-rgb, 6, 182, 212), 0.15);
  border: 1px solid rgba(var(--brand-rgb, 6, 182, 212), 0.3);
  border-radius: var(--radius, 8px);
  padding: 0 0.75rem;
  font-size: var(--text-xs, 0.75rem);
  color: var(--color-brand, #06b6d4);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.trade-modal .input-action-btn:hover {
  background: rgba(var(--brand-rgb, 6, 182, 212), 0.25);
  border-color: var(--color-brand, #06b6d4);
}

.trade-modal .input-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Symbol Autocomplete ========== */
.trade-modal .symbol-input-wrapper {
  position: relative;
}

.trade-modal .symbol-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-bg-card, #1a1a2e);
  border: 1px solid var(--color-border, #333);
  border-top: none;
  border-radius: 0 0 var(--radius, 8px) var(--radius, 8px);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.trade-modal .symbol-suggestions.visible {
  display: block;
}

.trade-modal .symbol-suggestion {
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-primary, #fff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s ease;
}

.trade-modal .symbol-suggestion:hover,
.trade-modal .symbol-suggestion.highlighted {
  background: rgba(var(--brand-rgb, 6, 182, 212), 0.15);
}

.trade-modal .symbol-suggestion .symbol-name {
  font-weight: 500;
}

.trade-modal .symbol-suggestion .symbol-price {
  color: var(--color-text-secondary, #888);
  font-size: var(--text-xs, 0.75rem);
}

/* ========== Hint Text ========== */
.trade-modal .field-hint {
  font-size: var(--text-xs, 0.75rem);
  color: var(--color-text-tertiary, #666);
  margin-top: 0.25rem;
}

.trade-modal .field-hint.error {
  color: var(--color-error, #ef4444);
}

/* ========== Tags Section ========== */
.trade-modal .tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
}

.trade-modal .tag-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-sm, 0.875rem);
  background: var(--color-bg-surface, rgba(255, 255, 255, 0.03));
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  border: 1px solid var(--color-border, #333);
  transition: all 0.15s ease;
}

.trade-modal .tag-checkbox:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.trade-modal .tag-checkbox input {
  margin: 0;
  accent-color: var(--color-brand, #06b6d4);
}

.trade-modal .tag-checkbox.checked {
  background: rgba(var(--brand-rgb, 6, 182, 212), 0.15);
  border-color: rgba(var(--brand-rgb, 6, 182, 212), 0.4);
}

/* ========== Market Context Checkbox ========== */
.trade-modal .market-context-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  cursor: pointer;
  margin-top: var(--space-4, 1rem);
}

.trade-modal .market-context-toggle input {
  margin: 0;
  accent-color: var(--color-brand, #06b6d4);
}

.trade-modal .market-context-toggle span {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-secondary, #888);
}

/* ========== Modal Footer ========== */
.trade-modal .modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-4, 1rem);
  padding-top: var(--space-4, 1rem);
  border-top: 1px solid var(--color-border, #333);
}

.trade-modal .modal-footer-actions {
  display: flex;
  gap: var(--space-2, 0.5rem);
}

.trade-modal .btn {
  padding: 0.625rem 1.25rem;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 500;
  border-radius: var(--radius, 8px);
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.trade-modal .btn-primary {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.trade-modal .btn-primary:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.35);
}

.trade-modal .btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-secondary, #888);
}

.trade-modal .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary, #fff);
}

.trade-modal .btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.trade-modal .btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ========== Form Error ========== */
.trade-modal .form-error {
  color: var(--color-error, #ef4444);
  font-size: var(--text-sm, 0.875rem);
  margin-top: var(--space-2, 0.5rem);
  padding: 0.5rem 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm, 4px);
  display: none;
}

.trade-modal .form-error.visible {
  display: block;
}

/* ========== Loading State ========== */
.trade-modal .price-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-text-secondary, #888);
  font-size: var(--text-xs, 0.75rem);
}

.trade-modal .price-loading .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(var(--brand-rgb, 6, 182, 212), 0.3);
  border-top-color: var(--color-brand, #06b6d4);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== Responsive ========== */
@media (max-width: 480px) {
  .trade-modal .modal-content {
    width: 95vw;
    max-height: 95vh;
  }

  .trade-modal .form-grid,
  .trade-modal .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .trade-modal .trade-form {
    padding: 1rem;
  }
}
