/*
 * App Global CSS
 * ----------------------------------------------------------------------------
 * Put style rules here that you want to apply globally. These styles are for
 * the entire app and not just one component. Additionally, this file can be
 * used as an entry point to import other CSS/Sass files to be included in the
 * output CSS.
 * For more information on global stylesheets, visit the documentation:
 * https://ionicframework.com/docs/layout/global-stylesheets
 */

/* Core CSS required for Ionic components to work properly */
@import "@ionic/angular/css/core.css";

/* Basic CSS for apps built with Ionic */
@import "@ionic/angular/css/normalize.css";
@import "@ionic/angular/css/structure.css";
@import "@ionic/angular/css/typography.css";
@import "@ionic/angular/css/display.css";

/* Optional CSS utils that can be commented out */
@import "@ionic/angular/css/padding.css";
@import "@ionic/angular/css/float-elements.css";
@import "@ionic/angular/css/text-alignment.css";
@import "@ionic/angular/css/text-transformation.css";
@import "@ionic/angular/css/flex-utils.css";

/**
 * Ionic Dark Mode
 * -----------------------------------------------------
 * For more info, please see:
 * https://ionicframework.com/docs/theming/dark-mode
 */

/* @import "@ionic/angular/css/palettes/dark.always.css"; */
/* @import "@ionic/angular/css/palettes/dark.system.css"; */
@import "@ionic/angular/css/palettes/dark.class.css";

ion-header {
  border: none !important;
  --border-width: 0 !important;
  box-shadow: none !important;
  --box-shadow: none !important;
  background: #121212 !important;
}

ion-header::after, ion-header::before {
  display: none !important;
}

ion-toolbar {
  --border-style: none !important;
  border: none !important;
  --border-width: 0 !important;
  --box-shadow: none !important;
  box-shadow: none !important;
  --background: transparent !important;
}

ion-toolbar::part(container) {
  border: none !important;
}

ion-app {
  background: #121212 !important;
}

/* High Contrast Mode Overrides */
html.high-contrast, body.high-contrast {
  color-scheme: light !important;
}

body.high-contrast {
  --ion-background-color: #ffffff;
  --ion-background-color-rgb: 255, 255, 255;
  --ion-text-color: #000000;
  --ion-text-color-rgb: 0, 0, 0;
  
  /* Primary color - complete set for shadow DOM components */
  --ion-color-primary: #000000;
  --ion-color-primary-rgb: 0, 0, 0;
  --ion-color-primary-contrast: #ffffff;
  --ion-color-primary-contrast-rgb: 255, 255, 255;
  --ion-color-primary-shade: #000000;
  --ion-color-primary-tint: #1a1a1a;

  /* Secondary color - complete set for shadow DOM components */
  --ion-color-secondary: #e67e22;
  --ion-color-secondary-rgb: 230, 126, 34;
  --ion-color-secondary-contrast: #ffffff;
  --ion-color-secondary-contrast-rgb: 255, 255, 255;
  --ion-color-secondary-shade: #cb6f1e;
  --ion-color-secondary-tint: #e98b38;

  /* Medium color - used by filter chips */
  --ion-color-medium: #92949c;
  --ion-color-medium-rgb: 146, 148, 156;
  --ion-color-medium-contrast: #ffffff;
  --ion-color-medium-contrast-rgb: 255, 255, 255;
  --ion-color-medium-shade: #808289;
  --ion-color-medium-tint: #9d9fa6;

  /* Light color */
  --ion-color-light: #f4f5f8;
  --ion-color-light-rgb: 244, 245, 248;
  --ion-color-light-contrast: #000000;
  --ion-color-light-contrast-rgb: 0, 0, 0;
  --ion-color-light-shade: #d7d8da;
  --ion-color-light-tint: #f5f6f9;

  /* Dark color */
  --ion-color-dark: #222428;
  --ion-color-dark-rgb: 34, 36, 40;
  --ion-color-dark-contrast: #ffffff;
  --ion-color-dark-contrast-rgb: 255, 255, 255;
  --ion-color-dark-shade: #1e2023;
  --ion-color-dark-tint: #383a3e;

  /* Light mode background step variables (light → dark) */
  --ion-background-color-step-50: #f2f2f2;
  --ion-background-color-step-100: #e6e6e6;
  --ion-background-color-step-150: #d9d9d9;
  --ion-background-color-step-200: #cccccc;
  --ion-background-color-step-250: #bfbfbf;
  --ion-background-color-step-300: #b3b3b3;
  --ion-background-color-step-350: #a6a6a6;
  --ion-background-color-step-400: #999999;
  --ion-background-color-step-450: #8c8c8c;
  --ion-background-color-step-500: #808080;
  --ion-background-color-step-550: #737373;
  --ion-background-color-step-600: #666666;
  --ion-background-color-step-650: #595959;
  --ion-background-color-step-700: #4d4d4d;
  --ion-background-color-step-750: #404040;
  --ion-background-color-step-800: #333333;
  --ion-background-color-step-850: #262626;
  --ion-background-color-step-900: #1a1a1a;
  --ion-background-color-step-950: #0d0d0d;

  /* Light mode text step variables (dark → light) */
  --ion-text-color-step-50: #0d0d0d;
  --ion-text-color-step-100: #1a1a1a;
  --ion-text-color-step-150: #262626;
  --ion-text-color-step-200: #333333;
  --ion-text-color-step-250: #404040;
  --ion-text-color-step-300: #4d4d4d;
  --ion-text-color-step-350: #595959;
  --ion-text-color-step-400: #666666;
  --ion-text-color-step-450: #737373;
  --ion-text-color-step-500: #808080;
  --ion-text-color-step-550: #8c8c8c;
  --ion-text-color-step-600: #999999;
  --ion-text-color-step-650: #a6a6a6;
  --ion-text-color-step-700: #b3b3b3;
  --ion-text-color-step-750: #bfbfbf;
  --ion-text-color-step-800: #cccccc;
  --ion-text-color-step-850: #d9d9d9;
  --ion-text-color-step-900: #e6e6e6;
  --ion-text-color-step-950: #f2f2f2;

  /* Legacy step variables (for older Ionic components) */
  --ion-color-step-50: #f4f5f8;
  --ion-color-step-100: #e0e0e0;
  --ion-color-step-150: #dcdcdc;
  --ion-color-step-200: #cccccc;
  --ion-color-step-250: #bfbfbf;
  --ion-color-step-300: #b3b3b3;
  --ion-color-step-350: #a6a6a6;
  --ion-color-step-400: #999999;
  --ion-color-step-450: #8c8c8c;
  --ion-color-step-500: #808080;
  --ion-color-step-550: #737373;
  --ion-color-step-600: #666666;
  --ion-color-step-650: #595959;
  --ion-color-step-700: #4d4d4d;
  --ion-color-step-750: #404040;
  --ion-color-step-800: #333333;
  --ion-color-step-850: #262626;
  --ion-color-step-900: #191919;
  --ion-color-step-950: #0d0d0d;

  /* Reset component-specific dark mode variables */
  --ion-item-background: #ffffff;
  --ion-card-background: #ffffff;
  --ion-toolbar-background: #ffffff;
  --ion-tab-bar-background: #ffffff;
  
  .bg-gradient {
    background: #ffffff !important;
  }
  
  .glass {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
    box-shadow: none !important;
  }

  ion-item.glass {
    --background: rgba(0, 0, 0, 0.05);
    h2 { color: #000000 !important; }
    p { color: rgba(0, 0, 0, 0.7) !important; }
  }

  .canto-number {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #000000 !important;
    border-color: rgba(0, 0, 0, 0.3) !important;
  }

  .custom-searchbar {
    --background: rgba(0, 0, 0, 0.05);
    --color: #000000;
    --placeholder-color: rgba(0, 0, 0, 0.4);
    --icon-color: #000000;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
  }

  .filter-btn {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
    
    ion-icon {
      color: #000000 !important;
    }

    &.active-btn {
      background: rgba(0, 0, 0, 0.1) !important;
      color: #000000 !important;
      border-color: #000000 !important;
    }

    &.is-filtered {
      background: rgba(230, 126, 34, 0.1) !important;
      border-color: #e67e22 !important;
      color: #e67e22 !important;
    }
  }

  .momento-chip {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
    opacity: 1 !important;

    &.active {
      background: #e67e22 !important;
      color: #ffffff !important;
      border-color: #e67e22 !important;
    }
  }

  ion-toolbar, ion-header, ion-content, .bg-gradient, .lyrics-view, .lyrics-container {
    --background: #ffffff !important;
    background: #ffffff !important;
    --color: #000000 !important;
    color: #000000 !important;
  }

  ion-header::after {
    display: none !important;
  }

  ion-toolbar {
    --border-style: none !important;
    border: none !important;
  }

  ion-toolbar {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    
    ion-title {
      color: #000000 !important;
    }
  }

  .canto-number {
    background: rgba(0, 0, 0, 0.08) !important;
    color: #000000 !important;
    border: 1px solid rgba(0, 0, 0, 0.3) !important;
  }

  .section.chorus {
    background: rgba(230, 126, 34, 0.08) !important;
    border-left-color: #e67e22 !important;
  }

  .section-label, .verse-num-label {
    color: #000000 !important;
    opacity: 0.7 !important;
  }

  .lyric-line {
    color: #000000 !important;
    &.active {
      background: rgba(0, 0, 0, 0.1) !important;
      color: #000000 !important;
      text-shadow: none !important;
      font-weight: 900 !important;
    }
  }

  .chord {
    color: #b03a2e !important;
    font-weight: 900 !important;
  }

  ion-footer {
    --background: #ffffff !important;
    background: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.2) !important;
  }

  .slim-controls .group {
    background: #f0f0f0 !important;
    border: 1px solid #cccccc !important;
    
    ion-icon, .page-indicator {
      color: #000000 !important;
    }
  }

  .global-player-toolbar {
    --background: #ffffff !important;
    background: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;

    &.glass {
      background: #ffffff !important;
      backdrop-filter: none !important;
      border-radius: 0 !important;
      box-shadow: none !important;
      border-left: none !important;
      border-right: none !important;
      border-bottom: none !important;
    }

    .controls-row ion-button {
      --color: #000000 !important;
    }
  }

  .transpose-indicator .val {
    color: #d35400 !important;
    font-weight: 900 !important;
  }

  .landscape-side-controls {
    background: #f8f8f8 !important;
    border-left: 2px solid #000000 !important;
    
    ion-icon, .side-indicator {
      color: #000000 !important;
    }
  }

  .version-badge {
    color: #000000 !important;
    background: transparent !important;
    font-weight: 400 !important;
    padding: 0 !important;
  }

  .special-list-banner {
    --background: #f8f8f8 !important;
    border-bottom: 2px solid #000000 !important;
    
    .banner-text {
      color: #000000 !important;
    }
  }

  /* Prevent button color/background issues in active/focus/hover states in high contrast */
  ion-button {
    --color-activated: var(--color) !important;
    --color-focused: var(--color) !important;
    --color-hover: var(--color) !important;
    
    &[fill="clear"], &[fill="outline"] {
      --background-activated: rgba(0, 0, 0, 0.1) !important;
      --background-focused: rgba(0, 0, 0, 0.08) !important;
      --background-hover: rgba(0, 0, 0, 0.05) !important;
    }
  }
}

.offline-badge-header {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  margin-right: 8px;

  ion-icon {
    font-size: 1.4rem;
  }
}

body.high-contrast .offline-badge-header {
  background: rgba(0, 0, 0, 0.05);
  color: #000000;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 6px;
  border-radius: 50%;
}

body.high-contrast .offline-thumb {
  background: rgba(0, 0, 0, 0.05) !important;
  color: #000000 !important;
  border: 1px solid rgba(0, 0, 0, 0.1);
  
  ion-icon {
    color: #000000 !important;
  }
  span {
    color: #000000 !important;
  }
}

.glass {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.filter-buttons {
  display: flex;
  gap: 8px;

  .filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);

    ion-icon {
      font-size: 0.9rem;
    }

    &.active-btn {
      background: rgba(var(--ion-color-secondary-rgb), 0.15) !important;
      color: var(--ion-color-secondary);
      border-color: var(--ion-color-secondary);
      font-weight: 600;
    }

    &.is-filtered {
      color: var(--ion-color-secondary);
      border-color: rgba(var(--ion-color-secondary-rgb), 0.5);
      background: rgba(var(--ion-color-secondary-rgb), 0.05);
    }

    &:active {
      transform: scale(0.95);
    }
  }
}

.bg-gradient {
  --background: radial-gradient(circle at top left, #2d3436 0%, #121212 100%);
  background: radial-gradient(circle at top left, #2d3436 0%, #121212 100%);
}

.outfit-font {
  font-family: 'Outfit', sans-serif;
}

/* Ensure high visibility of Action Sheet options in Dark Mode and High Contrast */
ion-action-sheet {
  --background: #1e1e1e !important;
  --color: #ffffff !important;
  
  button {
    color: #ffffff !important;
    --color: #ffffff !important;
  }

  .action-sheet-button {
    color: #ffffff !important;
    --color: #ffffff !important;
    
    &.action-sheet-selected {
      color: var(--ion-color-secondary) !important;
      --color: var(--ion-color-secondary) !important;
    }
  }
  
  .action-sheet-title {
    color: rgba(255, 255, 255, 0.7) !important;
  }
}

body.high-contrast ion-action-sheet {
  --background: #ffffff !important;
  --color: #000000 !important;

  button {
    color: #000000 !important;
    --color: #000000 !important;
  }

  .action-sheet-button {
    color: #000000 !important;
    --color: #000000 !important;

    &.action-sheet-selected {
      color: #e67e22 !important;
      --color: #e67e22 !important;
    }
  }

  .action-sheet-title {
    color: rgba(0, 0, 0, 0.7) !important;
  }
}
