import {StyleSheet} from 'react-native'

import {fontSize as fs, radius, space} from './tokens'

// atoms are flat style objects spread into RN style arrays
// leading atoms store multipliers (≤ 2); Typography normalizes them to px

export const atoms = {
  // flex
  flex_1: {flex: 1},
  flex_row: {flexDirection: 'row' as const},
  flex_col: {flexDirection: 'column' as const},
  flex_wrap: {flexWrap: 'wrap' as const},
  flex_nowrap: {flexWrap: 'nowrap' as const},
  flex_grow: {flexGrow: 1},
  flex_shrink: {flexShrink: 1},
  flex_0: {flex: 0},

  // align
  align_start: {alignItems: 'flex-start' as const},
  align_center: {alignItems: 'center' as const},
  align_end: {alignItems: 'flex-end' as const},
  align_baseline: {alignItems: 'baseline' as const},
  align_stretch: {alignItems: 'stretch' as const},
  align_self_start: {alignSelf: 'flex-start' as const},
  align_self_center: {alignSelf: 'center' as const},
  align_self_end: {alignSelf: 'flex-end' as const},
  align_self_stretch: {alignSelf: 'stretch' as const},

  // justify
  justify_start: {justifyContent: 'flex-start' as const},
  justify_center: {justifyContent: 'center' as const},
  justify_end: {justifyContent: 'flex-end' as const},
  justify_between: {justifyContent: 'space-between' as const},
  justify_around: {justifyContent: 'space-around' as const},

  // position
  absolute: {position: 'absolute' as const},
  relative: {position: 'relative' as const},
  inset_0: {top: 0, left: 0, right: 0, bottom: 0},

  // size
  w_full: {width: '100%' as const},
  h_full: {height: '100%' as const},
  w_0: {width: 0},
  h_0: {height: 0},

  // overflow
  overflow_hidden: {overflow: 'hidden' as const},

  // z-index
  z_10: {zIndex: 10},
  z_20: {zIndex: 20},
  z_30: {zIndex: 30},
  z_50: {zIndex: 50},

  // gap
  gap_xxs: {gap: space.xxs},
  gap_xs: {gap: space.xs},
  gap_sm: {gap: space.sm},
  gap_md: {gap: space.md},
  gap_lg: {gap: space.lg},
  gap_xl: {gap: space.xl},
  gap_2xl: {gap: space._2xl},
  gap_3xl: {gap: space._3xl},
  gap_4xl: {gap: space._4xl},

  // padding (all sides)
  p_xxs: {padding: space.xxs},
  p_xs: {padding: space.xs},
  p_sm: {padding: space.sm},
  p_md: {padding: space.md},
  p_lg: {padding: space.lg},
  p_xl: {padding: space.xl},
  p_2xl: {padding: space._2xl},
  p_3xl: {padding: space._3xl},

  // padding horizontal
  px_xxs: {paddingHorizontal: space.xxs},
  px_xs: {paddingHorizontal: space.xs},
  px_sm: {paddingHorizontal: space.sm},
  px_md: {paddingHorizontal: space.md},
  px_lg: {paddingHorizontal: space.lg},
  px_xl: {paddingHorizontal: space.xl},
  px_2xl: {paddingHorizontal: space._2xl},
  px_3xl: {paddingHorizontal: space._3xl},

  // padding vertical
  py_xxs: {paddingVertical: space.xxs},
  py_xs: {paddingVertical: space.xs},
  py_sm: {paddingVertical: space.sm},
  py_md: {paddingVertical: space.md},
  py_lg: {paddingVertical: space.lg},
  py_xl: {paddingVertical: space.xl},
  py_2xl: {paddingVertical: space._2xl},
  py_3xl: {paddingVertical: space._3xl},

  // padding top
  pt_xxs: {paddingTop: space.xxs},
  pt_xs: {paddingTop: space.xs},
  pt_sm: {paddingTop: space.sm},
  pt_md: {paddingTop: space.md},
  pt_lg: {paddingTop: space.lg},
  pt_xl: {paddingTop: space.xl},
  pt_2xl: {paddingTop: space._2xl},

  // padding bottom
  pb_xxs: {paddingBottom: space.xxs},
  pb_xs: {paddingBottom: space.xs},
  pb_sm: {paddingBottom: space.sm},
  pb_md: {paddingBottom: space.md},
  pb_lg: {paddingBottom: space.lg},
  pb_xl: {paddingBottom: space.xl},
  pb_2xl: {paddingBottom: space._2xl},

  // padding left/right
  pl_sm: {paddingLeft: space.sm},
  pl_md: {paddingLeft: space.md},
  pl_lg: {paddingLeft: space.lg},
  pr_xs: {paddingRight: space.xs},
  pr_sm: {paddingRight: space.sm},
  pr_md: {paddingRight: space.md},
  pr_lg: {paddingRight: space.lg},

  // margin
  m_xxs: {margin: space.xxs},
  m_xs: {margin: space.xs},
  m_sm: {margin: space.sm},
  m_md: {margin: space.md},
  m_lg: {margin: space.lg},
  m_xl: {margin: space.xl},

  mx_auto: {marginHorizontal: 'auto' as const},
  my_xxs: {marginVertical: space.xxs},
  my_xs: {marginVertical: space.xs},
  my_sm: {marginVertical: space.sm},
  my_md: {marginVertical: space.md},
  my_lg: {marginVertical: space.lg},
  my_xl: {marginVertical: space.xl},
  my_2xl: {marginVertical: space._2xl},

  mt_xxs: {marginTop: space.xxs},
  mt_xs: {marginTop: space.xs},
  mt_sm: {marginTop: space.sm},
  mt_md: {marginTop: space.md},
  mt_lg: {marginTop: space.lg},
  mt_xl: {marginTop: space.xl},
  mt_2xl: {marginTop: space._2xl},
  mt_auto: {marginTop: 'auto' as const},

  mb_xxs: {marginBottom: space.xxs},
  mb_xs: {marginBottom: space.xs},
  mb_sm: {marginBottom: space.sm},
  mb_md: {marginBottom: space.md},
  mb_lg: {marginBottom: space.lg},
  mb_xl: {marginBottom: space.xl},
  mb_2xl: {marginBottom: space._2xl},
  mb_auto: {marginBottom: 'auto' as const},

  ml_xs: {marginLeft: space.xs},
  ml_sm: {marginLeft: space.sm},
  ml_md: {marginLeft: space.md},
  ml_lg: {marginLeft: space.lg},
  ml_auto: {marginLeft: 'auto' as const},

  mr_xs: {marginRight: space.xs},
  mr_sm: {marginRight: space.sm},
  mr_md: {marginRight: space.md},
  mr_lg: {marginRight: space.lg},
  mr_auto: {marginRight: 'auto' as const},

  // border
  border: {borderWidth: StyleSheet.hairlineWidth},
  border_t: {borderTopWidth: StyleSheet.hairlineWidth},
  border_b: {borderBottomWidth: StyleSheet.hairlineWidth},
  border_l: {borderLeftWidth: StyleSheet.hairlineWidth},
  border_r: {borderRightWidth: StyleSheet.hairlineWidth},

  // radius
  rounded_xs: {borderRadius: radius.xs},
  rounded_sm: {borderRadius: radius.sm},
  rounded_md: {borderRadius: radius.md},
  rounded_lg: {borderRadius: radius.lg},
  rounded_full: {borderRadius: radius.full},
  curve_continuous: {borderCurve: 'continuous' as const},

  // text size — fontSize only; leading comes from a leading_* atom (ALF convention)
  text_xxs: {fontSize: fs.xxs},
  text_xs: {fontSize: fs.xs},
  text_sm: {fontSize: fs.sm},
  text_md: {fontSize: fs.md},
  text_lg: {fontSize: fs.lg},
  text_xl: {fontSize: fs.xl},
  text_2xl: {fontSize: fs._2xl},
  text_3xl: {fontSize: fs._3xl},

  // leading — stored as multipliers; Typography.normalizeTextStyles converts to px
  leading_tight: {lineHeight: 1.1},
  leading_snug: {lineHeight: 1.3},
  leading_normal: {lineHeight: 1.5},
  leading_relaxed: {lineHeight: 1.65},

  // text align
  text_left: {textAlign: 'left' as const},
  text_center: {textAlign: 'center' as const},
  text_right: {textAlign: 'right' as const},

  // font weight
  font_thin: {fontWeight: '100' as const},
  font_extralight: {fontWeight: '200' as const},
  font_light: {fontWeight: '300' as const},
  font_normal: {fontWeight: '400' as const},
  font_medium: {fontWeight: '500' as const},
  font_semi_bold: {fontWeight: '600' as const},
  font_bold: {fontWeight: '700' as const},
  font_extrabold: {fontWeight: '800' as const},
  font_black: {fontWeight: '900' as const},

  // shadow
  shadow_sm: {
    shadowColor: '#000',
    shadowOffset: {width: 0, height: 1},
    shadowOpacity: 0.05,
    shadowRadius: 2,
    elevation: 1,
  },
  shadow_md: {
    shadowColor: '#000',
    shadowOffset: {width: 0, height: 2},
    shadowOpacity: 0.1,
    shadowRadius: 4,
    elevation: 3,
  },
  shadow_lg: {
    shadowColor: '#000',
    shadowOffset: {width: 0, height: 4},
    shadowOpacity: 0.15,
    shadowRadius: 8,
    elevation: 5,
  },
}
