import {
  Settings,
  BarChart3,
  Layout,
  Keyboard,
  Smartphone,
  Eye,
  TrendingUp,
} from "lucide-react";
import { FieldDefinition, TabDefinition, TabColors } from "@/components/admin/settings";

// Tab definitions for Trading settings
export const TRADING_PRO_TABS: TabDefinition[] = [
  {
    id: "general",
    label: "General",
    icon: Settings,
    description: "Basic trading configuration",
  },
  {
    id: "features",
    label: "Features",
    icon: Layout,
    description: "Enable or disable features",
  },
  {
    id: "trading",
    label: "Trading",
    icon: TrendingUp,
    description: "Trading form and order settings",
  },
  {
    id: "display",
    label: "Display",
    icon: Eye,
    description: "Visual and display settings",
  },
];

// Tab colors for Trading settings
export const TRADING_PRO_TAB_COLORS: Record<string, TabColors> = {
  general: {
    bg: "bg-cyan-500/10",
    text: "text-cyan-500",
    border: "border-cyan-500/20",
    gradient: "from-cyan-500/20 via-cyan-400/10 to-transparent",
    glow: "shadow-cyan-500/20",
    iconBg: "bg-gradient-to-br from-cyan-500 to-cyan-600",
  },
  features: {
    bg: "bg-violet-500/10",
    text: "text-violet-500",
    border: "border-violet-500/20",
    gradient: "from-violet-500/20 via-violet-400/10 to-transparent",
    glow: "shadow-violet-500/20",
    iconBg: "bg-gradient-to-br from-violet-500 to-violet-600",
  },
  trading: {
    bg: "bg-emerald-500/10",
    text: "text-emerald-500",
    border: "border-emerald-500/20",
    gradient: "from-emerald-500/20 via-emerald-400/10 to-transparent",
    glow: "shadow-emerald-500/20",
    iconBg: "bg-gradient-to-br from-emerald-500 to-emerald-600",
  },
  display: {
    bg: "bg-amber-500/10",
    text: "text-amber-500",
    border: "border-amber-500/20",
    gradient: "from-amber-500/20 via-amber-400/10 to-transparent",
    glow: "shadow-amber-500/20",
    iconBg: "bg-gradient-to-br from-amber-500 to-amber-600",
  },
};

// Field definitions for Trading settings
export const TRADING_PRO_FIELD_DEFINITIONS: FieldDefinition[] = [
  // General Settings
  {
    key: "spotWallets",
    label: "Enable Spot Trading",
    type: "switch",
    description: "Enable spot trading functionality on the platform",
    category: "general",
    subcategory: "Features",
  },
  {
    key: "tradingProEnabled",
    label: "Enable New Trading Interface",
    type: "switch",
    description: "Use the new advanced trading interface instead of the classic trading page",
    category: "general",
    subcategory: "Interface",
  },
  {
    key: "marketLinkRoute",
    label: "Market Link Route",
    type: "select",
    description: "Choose where market links redirect to from markets page and home page",
    category: "general",
    subcategory: "Navigation",
    options: [
      { value: "trade", label: "Trading Page" },
      { value: "binary", label: "Binary Trading" },
    ],
  },
  {
    key: "spotChartEngine",
    label: "Chart Provider",
    type: "select",
    description: "Select the chart provider for spot/futures trading pages",
    category: "general",
    subcategory: "Chart",
    options: [
      { value: "TRADINGVIEW", label: "TradingView" },
      { value: "CHART_ENGINE", label: "Chart Engine (Addon)" },
    ],
  },
  {
    key: "tradingProDefaultLayout",
    label: "Default Layout",
    type: "select",
    description: "The default layout mode for new users",
    category: "general",
    subcategory: "Layout",
    options: [
      { value: "pro", label: "Pro (Full Featured)" },
      { value: "lite", label: "Lite (Simplified)" },
    ],
  },
  {
    key: "tradingProHotkeysEnabled",
    label: "Enable Hotkeys",
    type: "switch",
    description: "Allow users to use keyboard shortcuts",
    category: "general",
    subcategory: "Hotkeys",
  },
  {
    key: "tradingProAllowCustomLayouts",
    label: "Allow Custom Layouts",
    type: "switch",
    description: "Allow users to create and save custom layouts",
    category: "general",
    subcategory: "Layout",
  },
  {
    key: "tradingProMaxSavedLayouts",
    label: "Max Saved Layouts",
    type: "number",
    description: "Maximum number of custom layouts a user can save",
    category: "general",
    subcategory: "Layout",
    min: 1,
    max: 20,
  },

  // Features Settings
  {
    key: "tradingProAnalyticsEnabled",
    label: "Analytics",
    type: "switch",
    description: "Enable trading analytics and performance metrics",
    category: "features",
    subcategory: "Panels",
  },
  {
    key: "tradingProDepthChartEnabled",
    label: "Depth Chart",
    type: "switch",
    description: "Show depth chart visualization",
    category: "features",
    subcategory: "Panels",
  },
  {
    key: "tradingProRecentTradesEnabled",
    label: "Recent Trades",
    type: "switch",
    description: "Show recent trades panel",
    category: "features",
    subcategory: "Panels",
  },
  {
    key: "tradingProMarketsPanelEnabled",
    label: "Markets Panel",
    type: "switch",
    description: "Show markets/watchlist panel",
    category: "features",
    subcategory: "Panels",
  },
  {
    key: "tradingProOrdersPanelEnabled",
    label: "Orders Panel",
    type: "switch",
    description: "Show orders panel",
    category: "features",
    subcategory: "Panels",
  },
  {
    key: "tradingProPositionsPanelEnabled",
    label: "Positions Panel",
    type: "switch",
    description: "Show positions panel (for futures)",
    category: "features",
    subcategory: "Panels",
  },
  {
    key: "tradingProAdvancedOrdersEnabled",
    label: "Advanced Orders",
    type: "switch",
    description: "Enable advanced order types (stop-limit, etc.)",
    category: "features",
    subcategory: "Orders",
  },
  {
    key: "tradingProOneClickTradingEnabled",
    label: "One-Click Trading",
    type: "switch",
    description: "Enable one-click trading without confirmation",
    category: "features",
    subcategory: "Orders",
  },

  // Trading Settings
  {
    key: "tradingProConfirmOrders",
    label: "Order Confirmation",
    type: "switch",
    description: "Show confirmation dialog before placing orders",
    category: "trading",
    subcategory: "Orders",
  },
  {
    key: "tradingProShowEstimatedFees",
    label: "Show Estimated Fees",
    type: "switch",
    description: "Display estimated fees before placing orders",
    category: "trading",
    subcategory: "Orders",
  },
  {
    key: "tradingProShowOrderPreview",
    label: "Show Order Preview",
    type: "switch",
    description: "Display order preview before submission",
    category: "trading",
    subcategory: "Orders",
  },
  {
    key: "tradingProDefaultOrderType",
    label: "Default Order Type",
    type: "select",
    description: "The default order type for new orders",
    category: "trading",
    subcategory: "Orders",
    options: [
      { value: "limit", label: "Limit" },
      { value: "market", label: "Market" },
    ],
  },

  // Display Settings
  {
    key: "tradingProCompactMode",
    label: "Compact Mode",
    type: "switch",
    description: "Use compact display mode for denser information",
    category: "display",
    subcategory: "Layout",
  },
  {
    key: "tradingProShowSpread",
    label: "Show Spread",
    type: "switch",
    description: "Display bid/ask spread in the UI",
    category: "display",
    subcategory: "Data",
  },
  {
    key: "tradingProShowVolume",
    label: "Show Volume",
    type: "switch",
    description: "Display volume information",
    category: "display",
    subcategory: "Data",
  },
  {
    key: "tradingProPriceDecimals",
    label: "Price Decimals",
    type: "number",
    description: "Number of decimal places for price display",
    category: "display",
    subcategory: "Formatting",
    min: 0,
    max: 8,
  },
  {
    key: "tradingProAmountDecimals",
    label: "Amount Decimals",
    type: "number",
    description: "Number of decimal places for amount display",
    category: "display",
    subcategory: "Formatting",
    min: 0,
    max: 8,
  },
  {
    key: "tradingProMobileEnabled",
    label: "Mobile Optimized",
    type: "switch",
    description: "Enable mobile-optimized trading interface",
    category: "display",
    subcategory: "Mobile",
  },
];

// Default settings values
export const TRADING_PRO_DEFAULT_SETTINGS: Record<string, any> = {
  spotWallets: "true",
  tradingProEnabled: false, // Default to classic trading interface
  marketLinkRoute: "trade",
  spotChartEngine: "TRADINGVIEW",
  tradingProDefaultLayout: "pro",
  tradingProHotkeysEnabled: true,
  tradingProAllowCustomLayouts: true,
  tradingProMaxSavedLayouts: 5,
  tradingProAnalyticsEnabled: true,
  tradingProDepthChartEnabled: true,
  tradingProRecentTradesEnabled: true,
  tradingProMarketsPanelEnabled: true,
  tradingProOrdersPanelEnabled: true,
  tradingProPositionsPanelEnabled: true,
  tradingProAdvancedOrdersEnabled: true,
  tradingProOneClickTradingEnabled: false,
  tradingProConfirmOrders: true,
  tradingProShowEstimatedFees: true,
  tradingProShowOrderPreview: true,
  tradingProDefaultOrderType: "limit",
  tradingProCompactMode: false,
  tradingProShowSpread: true,
  tradingProShowVolume: true,
  tradingProPriceDecimals: 2,
  tradingProAmountDecimals: 6,
  tradingProMobileEnabled: true,
};
