/* ============================= */
/* CSS Custom Properties (Themes) */
/* ============================= */

@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&display=swap");

:root {
  --font-body: Arial, sans-serif;
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-xs: 0.75rem;

  --bg-body: #f7f9fc;
  --text-body: #000000;

  --bg-panel: #e8f4f8;
  --border-panel: #2196f3;
  --text-panel: inherit;

  --bg-input: #ffffff;
  --border-input: #ccc;
  --bg-input-addon: #f0f0f0;

  --bg-dropdown: #ffffff;
  --border-dropdown: #dcdcdc;
  --shadow-dropdown: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.08);

  --bg-result-hover: #f3f6fa;
  --bg-result-focus: #e8f0fe;
  --border-result: #eee;
  --border-result-divider: #f0f0f0;
  --accent-focus: #2196f3;

  --bg-game-card: #e8f4f8;
  --border-game-card: #2196f3;
  --text-muted: #666666;
  --text-danger: #d32f2f;

  --btn-primary-bg: #2196f3;
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #1976d2;
  --btn-primary-active: #0d47a1;

  --btn-main-bg: #2196f3;
  --btn-main-hover: #1976d2;
  --btn-main-active: #0d47a1;

  --btn-plus-bg: #9c27b0;
  --btn-plus-hover: #7b1fa2;
  --btn-plus-active: #4a148c;

  --btn-complete-bg: #4caf50;
  --btn-complete-hover: #45a049;
  --btn-complete-active: #388e3c;

  --icon-fill: #ffffff;

  --border-preview: #ccc;

  --bar-track-bg: #ddd;
  --bar-fill-bg: #4caf50;

  --bg-texture: none;
}

[data-theme="medieval"] {
  --font-body: "Cinzel", serif;

  --bg-body: #0a0806;
  --text-body: #d4bf8a;

  --bg-panel: #1a1410;
  --border-panel: #8b7355;
  --text-panel: #d4bf8a;

  --bg-input: #1a1410;
  --border-input: #6b4f2e;
  --bg-input-addon: #2a1f14;

  --bg-dropdown: #1a1410;
  --border-dropdown: #6b4f2e;
  --shadow-dropdown: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.5);

  --bg-result-hover: #2a1f14;
  --bg-result-focus: #3a2a1a;
  --border-result: #2a1f14;
  --border-result-divider: #2a1f14;
  --accent-focus: #c4a96a;

  --bg-game-card: #1a1410;
  --border-game-card: #c4a96a;
  --text-muted: #a08a66;
  --text-danger: #a03020;

  --btn-primary-bg: #8b7355;
  --btn-primary-text: #0a0806;
  --btn-primary-hover: #a08060;
  --btn-primary-active: #6b5535;

  --btn-main-bg: #8b7355;
  --btn-main-hover: #a08060;
  --btn-main-active: #6b5535;

  --btn-plus-bg: #6b3a6b;
  --btn-plus-hover: #8b4a8b;
  --btn-plus-active: #4a2a4a;

  --btn-complete-bg: #4a6b3a;
  --btn-complete-hover: #5a8b4a;
  --btn-complete-active: #3a4a2a;

  --icon-fill: #0a0806;

  --border-preview: #6b4f2e;

  --bar-track-bg: #2a1f14;
  --bar-fill-bg: #c4a96a;

  --bg-texture:
    radial-gradient(
      ellipse at 80% 10%,
      rgba(196, 169, 106, 0.04) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 20% 90%,
      rgba(139, 115, 85, 0.04) 0%,
      transparent 50%
    );
}

/* Texture overlay using pseudo-element trick */
[data-theme="medieval"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='none'/%3E%3Crect x='0' y='0' width='1' height='1' fill='rgba(0,0,0,0.04)'/%3E%3Crect x='2' y='1' width='1' height='1' fill='rgba(0,0,0,0.04)'/%3E%3Crect x='3' y='3' width='1' height='1' fill='rgba(0,0,0,0.03)'/%3E%3Crect x='1' y='2' width='1' height='1' fill='rgba(255,255,255,0.02)'/%3E%3C/svg%3E");
  opacity: 0.5;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-body);
  padding: 1.5rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  align-items: flex-start;
}

#auth-section {
  flex: 1 1 100%;
  text-align: center;
}

#app-section {
  flex: 1 1 25rem;
  min-width: 12.5rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#themeSelect {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: var(--font-size-sm);
}

main,
header,
hr,
h2 {
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
}

main {
  margin-top: 2.5rem;
}

#configHeading {
  text-align: center;
}

#applyStart {
  grid-column-start: 1;
  grid-row-start: 2;
}

#applyMax {
  grid-row: span 2 / span 2;
  grid-column-start: 2;
  grid-row-start: 1;
}

/* ============================= */
/* Layout Improvements */
/* ============================= */

.container {
  margin: 2.5rem auto; /* center horizontally */
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  align-items: flex-start;
}

/* Equal width columns */
.col {
  flex: 1 1 25rem; /* equal width */
  min-width: 12.5rem;
  display: grid;
  grid-template-columns: 5.625rem 1fr; /* label column + input column */
  gap: 0.75rem 1rem;
  align-items: center;
}

/* Make labels not stack */
.col label {
  display: contents;
}

/* Make inputs/selects stretch nicely */
.col input,
.col select {
  width: 100%;
  box-sizing: border-box;
}

/* Make sliders span full width */
.col input[type="range"] {
  grid-column: 1 / -1;
}

@media (max-width: 37.5rem) {
  .percent-row {
    grid-template-columns: 1fr;
  }
}

.percent-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 3fr; /* 1 column + 3 columns */
  gap: 0.5rem;
  align-items: center;
}

/* Percentage input column */
.input-group {
  display: flex;
  align-items: stretch;
  max-width: 6.25rem;
}

.input-group input {
  border: 1px solid var(--border-input);
  border-right: none;
  padding: 0.5rem;
  width: 100%;
  border-radius: 0.25rem 0 0 0.25rem;
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 0.625rem;
  background: var(--bg-input-addon);
  border: 1px solid var(--border-input);
  border-radius: 0 0.25rem 0.25rem 0;
  font-size: 0.875rem;
}

/* Slider starts in column 2 and spans to the end */
.percent-row input[type="range"] {
  grid-column: 2 / -1;
  width: 100%;
}

/* Compact time row (4 columns) */
.time-row {
  grid-column: 1 / -1; /* span full width of the col grid */
  display: grid;
  /* grid-template-columns: auto 140px auto 140px; */
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.75rem 1rem;
  align-items: center;
}

/* Prevent these inputs from stretching */
.time-row input {
  /* width: 140px; */
}

/* Make labels inline instead of block */
.time-row label {
  margin: 0;
}

.theme-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-row label {
  margin: 0;
  white-space: nowrap;
}

.theme-row select {
  width: auto;
  min-width: 10rem;
}

.preview-section {
  max-width: 56rem;
  margin: 2.5rem auto;
  text-align: center;
}

.preview-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

#previewFrame {
  width: 100%;
  height: 25rem;
  border: 1px solid var(--border-preview);
  border-radius: 0.375rem;
}

/* 
 *
 * Search bar
 *
 */

/* ============================= */
/* Search Autocomplete Dropdown */
/* ============================= */

.search-wrapper {
  position: relative;
  max-width: 25rem; /* controls width */
}

#search {
  width: 100%;
  box-sizing: border-box;
}

/* Dropdown container */
#results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%; /* same as search input */
  background: var(--bg-dropdown);
  border: 1px solid var(--border-dropdown);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: var(--shadow-dropdown);
  max-height: 18.75rem;
  overflow-y: auto;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

/* Hide if empty */
#results:empty {
  display: none;
}

/* Individual result items */
.game {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  transition:
    background 0.15s ease,
    transform 0.05s ease;
}

/* Hover state */
.game:hover {
  background: var(--bg-result-hover);
}

.game:focus {
  outline: none;
  background: var(--bg-result-focus);
}

/* Active click feedback */
.game:active {
  transform: scale(0.98);
}

/* Optional: subtle divider */
.game + .game {
  border-top: 1px solid var(--border-result-divider);
}

/* Smooth appearance */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-0.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================= */
/* Selected Game Card */
/* ============================= */

/* Steam Library Search Styles */

input {
  padding: 0.5rem;
  width: 100%;
  font-size: 1rem;
  box-sizing: border-box;
  background: var(--bg-input);
  color: var(--text-body);
}

select {
  padding: 0.5rem;
  width: 100%;
  font-size: 1rem;
  box-sizing: border-box;
  cursor: pointer;
  background: var(--bg-input);
  color: var(--text-body);
  border: 1px solid var(--border-input);
  border-radius: 0.25rem;
}

input[type="color"] {
  padding: 0.25rem;
  height: 2.5rem;
  cursor: pointer;
  border: 1px solid var(--border-input);
}

button {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  cursor: pointer;
}

.game {
  margin: 0;
  cursor: pointer;
  padding: 0.625rem;
  border-bottom: 1px solid var(--border-result);
  transition: background-color 0.2s;
  outline: none;
}

.game:last-child {
  border-bottom: none;
}

.game:hover {
  background-color: var(--bg-result-hover);
}

.game:focus {
  background-color: var(--bg-result-focus);
  border-left: 3px solid var(--accent-focus);
  padding-left: 0.4375rem;
}

img {
  vertical-align: middle;
  margin-right: 0.625rem;
}

#selected-game {
  flex: 1 1 25rem;
  min-width: 12.5rem;
  margin-top: 0.625rem;
  padding: 0.625rem;
  background-color: var(--bg-game-card);
  color: var(--text-panel);
  border-radius: 0.25rem;
  border-left: 4px solid var(--border-game-card);
  font-size: 0.875rem;

  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.5rem;
}

#selected-game:empty {
  visibility: hidden;
  min-height: 3rem;
}

.selected-game-content {
  display: flex;
  align-items: center;
  margin-bottom: 0.625rem;
}

.apply-section {
  margin-top: 0.3125rem;
}

.apply-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: 0.3125rem;
}

.clear-selection {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-muted);
  cursor: pointer;
  margin-right: 0.625rem;
  line-height: 1;
  transition: color 0.2s;
  user-select: none;
}

.clear-selection:hover {
  color: var(--text-danger);
}

.apply-time-btn {
  padding: 0.375rem 0.75rem;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 0.1875rem;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.apply-time-btn:hover {
  background-color: var(--btn-primary-hover);
}

.apply-time-btn:active {
  background-color: var(--btn-primary-active);
}

.apply-max-btn {
  padding: 0.375rem 0.75rem;
  color: var(--btn-primary-text);
  border: none;
  border-radius: 0.1875rem;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
}

.apply-max-btn:last-child {
  margin-bottom: 0;
}

.apply-max-btn-main {
  background-color: var(--btn-main-bg);
}

.apply-max-btn-main:hover {
  background-color: var(--btn-main-hover);
}

.apply-max-btn-main:active {
  background-color: var(--btn-main-active);
}

.apply-max-btn-plus {
  background-color: var(--btn-plus-bg);
}

.apply-max-btn-plus:hover {
  background-color: var(--btn-plus-hover);
}

.apply-max-btn-plus:active {
  background-color: var(--btn-plus-active);
}

.apply-max-btn-complete {
  background-color: var(--btn-complete-bg);
}

.apply-max-btn-complete:hover {
  background-color: var(--btn-complete-hover);
}

.apply-max-btn-complete:active {
  background-color: var(--btn-complete-active);
}

/*
.max-time-buttons {
  display: flex;
  flex-direction: column;
}
*/

.max-time-loading,
.max-time-error {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-style: italic;
}

.steam-icon {
  width: 1rem;
  height: 1rem;
  fill: var(--icon-fill);
}

#results {
  max-height: 25rem;
  overflow-y: auto;
  border: 1px solid var(--border-dropdown);
  border-radius: 0.25rem;
  background-color: var(--bg-dropdown);
}

#results:empty {
  border: none;
}

/* Progress Bar Configuration Styles */

#startInputLabel {
  display: none;
}

#maxInputLabel {
  display: none;
}

#previewFrame {
  width: 100%;
  height: 25rem;
  border: 1px solid var(--border-preview);
}
