/* General Styling with Material Design 3 Color Roles 
  This new color system uses semantic names from Google's Material Design 3
  to ensure consistency and accessibility for both light and dark themes.
*/
:root {
  /* Primary colors (main brand/accent color) */
  --md-sys-color-primary: #00639B;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #CFE5FF;
  --md-sys-color-on-primary-container: #001E33;

  /* Secondary colors (less prominent actions) */
  --md-sys-color-secondary: #51606F;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #D4E4F6;
  --md-sys-color-on-secondary-container: #0D1D2A;

  /* Surface colors (backgrounds of components) */
  --md-sys-color-surface: #F8F9FF; /* Main container background */
  --md-sys-color-surface-variant: #DEE3EB; /* Input/Output boxes */
  --md-sys-color-on-surface: #191C1F; /* Main text color */
  --md-sys-color-on-surface-variant: #42474E; /* Subtler text, inactive tabs */
  
  /* Background color (the main page background) */
  --md-sys-color-background: #F8F9FF;
  --md-sys-color-on-background: #191C1F;

  /* Outline color (borders) */
  --md-sys-color-outline: #72787E;
  --md-sys-color-outline-variant: #C2C7CE;

  /* Shadow color */
  --md-sys-color-shadow: rgba(0, 0, 0, 0.2);
}

body.dark-mode {
  /* Primary colors (Dark Theme) */
  --md-sys-color-primary: #99CBFF;
  --md-sys-color-on-primary: #003353;
  --md-sys-color-primary-container: #004A75;
  --md-sys-color-on-primary-container: #CFE5FF;

  /* Secondary colors (Dark Theme) */
  --md-sys-color-secondary: #B8C8DA;
  --md-sys-color-on-secondary: #233240;
  --md-sys-color-secondary-container: #394857;
  --md-sys-color-on-secondary-container: #D4E4F6;
  
  /* Surface colors (Dark Theme) */
  --md-sys-color-surface: #111417; /* Main container background */
  --md-sys-color-surface-variant: #42474E; /* Input/Output boxes */
  --md-sys-color-on-surface: #E1E2E6; /* Main text color */
  --md-sys-color-on-surface-variant: #C2C7CE; /* Subtler text, inactive tabs */

  /* Background color (Dark Theme) */
  --md-sys-color-background: #111417;
  --md-sys-color-on-background: #E1E2E6;

  /* Outline color (Dark Theme) */
  --md-sys-color-outline: #8C9198;
  --md-sys-color-outline-variant: #42474E;

  /* Shadow color */
  --md-sys-color-shadow: rgba(0, 0, 0, 0.4);
}


*,
*:after,
*:before {
  box-sizing: border-box;
}

body {
  font-family: "Google Sans", sans-serif;
  color: var(--md-sys-color-on-background);
  background-color: var(--md-sys-color-background);
  font-size: 16px;
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

.container {
  width: 100%;
  max-width: 800px;
  background: var(--md-sys-color-surface);
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px var(--md-sys-color-shadow);
  animation: fadeIn 0.5s ease-in-out;
  transition: background-color 0.3s;
  border: 1px solid var(--md-sys-color-outline-variant);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0;
    font-size: 28px;
    color: var(--md-sys-color-on-surface);
}

.page-header p {
    margin: 5px 0 0;
    color: var(--md-sys-color-on-surface-variant);
}

.theme-btn {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    padding: 5px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    line-height: 1;
    transition: background-color 0.3s;
}

.theme-btn:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
}


/* Tabs */
.tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.tab-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 18px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  transition: all 0.3s ease;
  position: relative;
  border-bottom: 2px solid transparent; /* Prepare for active state */
}

.tab-link.active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

/* Remove the ::after pseudo-element as we now use the border */
.tab-link.active::after {
    display: none;
}


.tab-content {
  display: none;
  animation: slideIn 0.5s forwards;
}

.tab-content.active {
  display: block;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}


h2 {
    text-align: center;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 25px;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
}

.radio-group {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

label {
  display: flex;
  cursor: pointer;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  margin: 5px;
}
label input {
  position: absolute;
  left: -9999px;
}
label input:checked + span {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
label input:checked + span:before {
  box-shadow: inset 0 0 0 0.4375em var(--md-sys-color-primary);
}
label span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5em 1em;
  border-radius: 99em;
  transition: 0.25s ease;
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
}
label span:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, var(--md-sys-color-surface-variant));
}
label span:before {
  display: flex;
  flex-shrink: 0;
  content: "";
  background-color: var(--md-sys-color-surface);
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  margin-right: 0.5em;
  transition: 0.25s ease;
  box-shadow: inset 0 0 0 0.125em var(--md-sys-color-primary);
}


.input-box, .output-box, .key-input {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline);
    font-family: 'Google Sans', sans-serif;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s, color 0.3s;
    resize: vertical;
    min-height: 120px;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
}

.key-input {
    min-height: auto;
}

.input-box:focus, .output-box:focus, .key-input:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 25%, transparent);
    outline: none;
}

.output-box {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 5%, var(--md-sys-color-surface-variant));
}

.convert-btn, .copy-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.convert-btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    margin-bottom: 10px;
}

.convert-btn:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-primary) 10%, var(--md-sys-color-primary));
    transform: translateY(-2px);
}

.copy-btn {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
}

.copy-btn:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-secondary) 10%, var(--md-sys-color-secondary));
    transform: translateY(-2px);
}
