@use '@angular/material' as mat;

// ---- Themes ----
$light-theme: mat.define-theme((color: (theme-type: light, primary: mat.$cyan-palette, tertiary: mat.$orange-palette ),
      typography: (brand-family: 'Inter, Roboto, Arial, sans-serif', bold-weight: 600),
      density: (scale: 0),
    ));

$dark-theme: mat.define-theme((color: (theme-type: dark, primary: mat.$cyan-palette, tertiary: mat.$orange-palette ),
    ));

// ---- Core + Components ----
@include mat.core-theme($light-theme);
@include mat.all-component-themes($light-theme);

.dark {
  @include mat.all-component-colors($dark-theme);
}

/* ---- Custom variables (bridge Material tokens to CSS vars for Tailwind) ---- */
:root {
  --app-maxWidth: 1200px;
  --app-bg: #{mat.get-theme-color($light-theme, surface-container-low)};
  --app-fg: #{mat.get-theme-color($light-theme, on-surface)};
  --app-logo-bg: #313131;
  --app-card-background: #fafafa;
  --app-topbar-bg: var(--app-card-background);

  --card-radius: 18px;
  --card-bg: var(--app-card-background);
  --card-border-inset: rgba(255, 255, 255, 0.35);
  --card-border-inset-dark: rgba(0, 0, 0, 0.35);

  --link-color: #38a7ff;
  --link-color-hover: #66bfff;
}

.dark {
  --app-bg: #{mat.get-theme-color($dark-theme, surface-variant)};
  --app-fg: #{mat.get-theme-color($dark-theme, on-surface)};
  --app-card-background: #313131;
  --app-logo-bg: #313131;
  --app-topbar-bg: var(--app-card-background);

  --card-bg: var(--app-card-background);

  --link-color: #6dbcff;
  --link-color-hover: #9ad2ff;
}

/* ---- Material component theme transitions ---- */
.mat-toolbar,
.mat-mdc-card,
.mat-sidenav,
.mat-mdc-menu-panel,
.mat-mdc-dialog-container,
.mat-mdc-select-panel,
.mat-mdc-snack-bar-container,
.cdk-overlay-pane {
  transition:
    background-color 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    fill 220ms ease;
}

/* ---- Material card overrides ---- */
.mat-mdc-card {
  position: relative;
  border-radius: var(--card-radius) !important;
  background: var(--card-bg) !important;
  overflow: hidden;
  border: none;
  transition: box-shadow 200ms ease, transform 200ms ease;
}

.mat-mdc-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 var(--card-border-inset),
    inset 0 -1px 0 var(--card-border-inset-dark);
}

/* ---- Material accordion/expansion panel overrides ---- */
.mat-accordion {
  display: grid;
  gap: 8px;
}

.mat-accordion .mat-expansion-panel {
  border-radius: var(--card-radius) !important;
  background: var(--card-bg) !important;
  overflow: hidden;
  border: none !important;
}

.mat-accordion .mat-expansion-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 var(--card-border-inset),
    inset 0 -1px 0 var(--card-border-inset-dark);
}

.mat-expansion-panel-header {
  background: transparent !important;
}

.mat-expansion-panel-body {
  padding-top: 0;
}

/* ---- Material dialog overrides ---- */
.image-dialog-panel .mat-mdc-dialog-surface {
  border-radius: 16px;
  overflow: hidden;
}

.image-dialog-panel .mat-mdc-dialog-content {
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  max-height: none !important;
}

.image-dialog-panel .mat-mdc-dialog-container {
  padding: 0;
}

/* ---- Material menu overrides ---- */
.mat-mdc-menu-item .mdc-list-item__primary-text {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.mat-mdc-menu-item .kbd {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  padding: 0 .35rem;
  opacity: .65;
}

.mat-mdc-menu-item .mat-icon {
  width: 20px;
  height: 20px;
  font-size: 20px;
}

.mat-mdc-menu-item .flag-icon {
  width: 20px !important;
  height: 14px !important;
  object-fit: cover;
  border-radius: 2px;
  margin-right: .5rem;
  vertical-align: middle;
}

.mat-mdc-menu-panel {
  border-radius: 10px !important;
  border: 1px solid rgba(0, 0, 0, .14);
}

.dark .mat-mdc-menu-panel {
  border-color: rgba(255, 255, 255, .06);
}

/* ---- Swiper shadow DOM (::part cannot be Tailwind) ---- */
.my-swiper::part(button-prev),
.my-swiper::part(button-next) {
  width: 35px;
  height: 35px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.my-swiper::part(button-prev):hover,
.my-swiper::part(button-next):hover {
  background: rgba(0, 0, 0, .75);
}

.my-swiper::part(pagination) {
  bottom: 12px;
}
