/**
 * Chatlog Magician - Modern CSS
 * Enhanced styling while preserving all original functionality
 */

:root {
  /* Color variables */
  --bg-color: #24282e;
  --text-color: #fff;
  --input-bg: rgba(255, 255, 255, 0.15);
  --input-bg-focus: rgba(255, 255, 255, 0.25);
  --button-bg: #111;
  --button-bg-hover: #555;
  --button-border: rgba(255, 255, 255, 0.2);
  --button-border-hover: rgba(255, 255, 255, 0.4);
  --success-color: #66bb6a;
  --button-shadow: rgba(0, 0, 0, 0.5);
  --scrollbar-thumb: rgba(255, 255, 255, 0.5);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 1);
  
  /* Text colors */
  --me-color: #c2a3da;
  --ame-color: #c2a3da;
  --darkgrey-color: #5a5a5b;
  --grey-color: #939799;
  --lightgrey-color: #c6c4c4;
  --death-color: #f00000;
  --yellow-color: #fbf724;
  --green-color: #56d64b;
  --money-color: #56d64b;
  --orange-color: #eda841;
  --whisper-color: #eda841;
  --blue-color: #3896f3;
  --white-color: #f1f1f1;
  --radio-color: #ffec8b;
  --radio2-color: #a19558;
  --dep-color: #ccca15;
  --vessel-color: #33C1C9;
  --toyou-color: #ff00bc;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Border radius */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 1rem;
  
  /* Font sizes */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
}

/* Base styles */
body {
  font-family: Arial, sans-serif;
  width: 100%;
  background: var(--bg-color);
  margin: 0;
  color: var(--text-color);
}

html::-webkit-scrollbar {
  width: 0px;
  background-color: transparent;
}

/* Textarea styling */
.textarea-input {
  font-family: Arial, sans-serif;
  -webkit-font-smoothing: none !important;
  width: 100%;
  border-radius: var(--border-radius-md);
  resize: none;
  background-color: var(--input-bg);
  color: var(--text-color);
  border: none;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-sm);
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  /* padding-left: 50px; */
  height: 150px;
  font-size: var(--font-size-xs);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.textarea-input:focus {
  outline: none;
  background-color: var(--input-bg-focus);
  border: none;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.textarea-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

/* Scrollbar styling */
.textarea-input::-webkit-scrollbar {
  width: 6px;
}

.textarea-input::-webkit-scrollbar-track {
  background: transparent;
}

.textarea-input::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
}

.textarea-input::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Container styling */
.textarea-container {
  position: relative;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Output styling */
.generated {
  display: inline;
  position: relative;
  padding: 0.1em 0.2em 0.1em 0.2em;
  white-space: pre-line;
  word-wrap: break-word;
  line-height: 1.3;
  background-color: transparent;
  color: var(--text-color);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  border-radius: 0;
  background-clip: padding-box;
  margin-bottom: 2px;
  z-index: 1;
}

.background-active {
  background-color: rgb(0, 0, 0);
  padding: 10px;
}

#output {
  position: relative;
  padding-bottom: 15px;
  border-radius: var(--border-radius-md);
  background-color: transparent;
  box-sizing: border-box;
  overflow: visible;
  line-height: 0;
  -webkit-font-smoothing: none !important;
  font-weight: 700;
  color: var(--text-color);
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  letter-spacing: 0;
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-lg);
  padding: var(--spacing-lg);
}

/* Text color classes */
.me { color: var(--me-color); }
.ame { color: var(--ame-color); }
.darkgrey { color: var(--darkgrey-color); }
.grey { color: var(--grey-color); }
.lightgrey { color: var(--lightgrey-color); }
.death { color: var(--death-color); }
.yellow { color: var(--yellow-color); }
.green, .money { color: var(--green-color); }
.orange, .whisper { color: var(--orange-color); }
.blue { color: var(--blue-color); }
.white { color: var(--white-color); }
.radioColor { color: var(--radio-color); }
.radioColor2 { color: var(--radio2-color); }
.depColor { color: var(--dep-color); }
.vesseltraffic { color: var(--vessel-color); }
.toyou { color: var(--toyou-color); }

/* Button styles */
.button {
  padding: 0.85em 1em;
  font-size: var(--font-size-lg);
  border-radius: 0;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
  border: 1px solid var(--button-border);
  cursor: pointer;
  height: auto;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--button-border-hover);
  box-shadow: 0 2px 10px var(--button-shadow);
  transform: translateY(-2px);
}

.button:focus {
  outline: 2px solid var(--text-color);
  outline-offset: 2px;
}

.button.success,
.button.success.disabled,
.button.success[disabled] {
  background-color: rgba(102, 187, 106, 0.15) !important;
  color: var(--success-color) !important;
  border: 1px solid rgba(102, 187, 106, 0.3) !important;
}

.button.success:hover,
.button.success:focus {
  background-color: rgba(102, 187, 106, 0.25) !important;
  border-color: var(--success-color) !important;
  color: var(--success-color) !important;
}

/* Add button: match Download button success colors */
#applyFilterBtn.button {
  background-color: rgba(102, 187, 106, 0.15) !important;
  color: var(--success-color) !important;
  border: 1px solid rgba(102, 187, 106, 0.3) !important;
}

#applyFilterBtn.button:hover,
#applyFilterBtn.button:focus {
  background-color: rgba(102, 187, 106, 0.25) !important;
  border-color: var(--success-color) !important;
  color: var(--success-color) !important;
}

/* Input group styling */
.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}

.input-group input {
  padding: 0.6rem;
  border-radius: var(--border-radius-md) !important;
  flex: 1;
  border: 1px solid #666;
  box-sizing: border-box;
  font-size: var(--font-size-md);
  height: auto;
  margin-bottom: 0;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.input-group input:hover,
.input-group input:focus {
  border-color: #999;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

#font-label,
#lineLengthInput,
#characterNameInput {
  border-radius: 0 !important;
  height: 44px !important;
  padding-top: 0;
  padding-bottom: 0;
}

#applyFilterBtn {
  height: 44px !important;
}

.name-input-wrap {
  position: relative;
  flex: 1;
}

.name-input-wrap #characterNameInput {
  width: 100%;
  padding-right: 2.2rem;
}

.history-input-arrow {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 999px;
  color: #222;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.7rem;
}

#historyDropdownArrowIcon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
}

#historyDropdownArrow[aria-expanded="false"] #historyDropdownArrowIcon {
  transform: rotate(-90deg);
}

#historyDropdownArrow[aria-expanded="true"] #historyDropdownArrowIcon {
  transform: rotate(90deg);
}

.character-history-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  background: #111111;
  border: 1px solid rgb(39, 39, 39);
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  z-index: 60;
  display: none;
  max-height: 180px;
  overflow-y: auto;
}

.name-input-wrap.history-open .character-history-dropdown {
  display: block;
}

.character-history-empty {
  padding: 0.65rem 0.75rem;
  color: #ffffff;
  font-size: 0.95rem;
}

.character-history-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.2rem;
  transition: all 0.2s ease;
}

.character-history-item:hover {
  background: #161616;
}

.character-history-select {
  flex: 1;
  border: 0;
  text-align: left;
  background: transparent;
  color: #d7e4f7;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.character-history-remove {
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  background: transparent;
  color: #9fb2cb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.character-history-remove:hover {
  color: #ff7070;
}

.character-history-remove svg {
  width: 14px;
  height: 14px;
}

.chatlog-history-panel {
  position: fixed;
  top: 1rem;
  right: -390px;
  width: min(360px, calc(100vw - 1.5rem));
  height: calc(100vh - 2rem);
  border: none;
  border-radius: 6px;
  box-shadow: 0 0 26px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  z-index: 80;
  transition: right 0.25s ease;
}

.chatlog-history-panel.is-open {
  right: 0.50rem;
}

.chatlog-history-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 88px;
  border: 0;
  background: #3a3f46;
  color: #dce9fb;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 81;
  transition: all 0.25s ease;
}

.chatlog-history-toggle:hover {
  background: #181C24;
}

.chatlog-history-toggle svg {
  width: 20px;
  height: 20px;
}

.chatlog-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: none;
  background: var(--bg-color);
}

.chatlog-history-header h3 {
  margin: 0;
  font-size: 1.3rem;
  color: #ffffff;
}

#clearChatlogHistoryBtn {
  margin: 0;
  padding: 0.45rem 0.75rem;
  height: auto;
  font-size: 0.8rem;
}

#chatlogHistoryList {
  height: calc(100% - 62px);
  overflow-y: auto;
  padding: 0.35rem;
  background: var(--bg-color);
}

.chatlog-history-empty {
  color: #9fb2cb;
  text-align: center;
  padding: 2.5rem 1rem;
}

.chatlog-history-empty-title {
  color: #f1f6ff;
  font-size: 1rem;
  margin-bottom: 0.45rem;
}

.chatlog-history-empty-subtitle {
  font-size: 0.9rem;
}

.chatlog-history-entry {
  width: 100%;
  border: none;
  border-radius: 6px;
  background: var(--input-bg);
  color: #dbe7f8;
  text-align: left;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chatlog-history-entry:last-child {
  margin-bottom: 0;
}

.chatlog-history-entry:hover {
  background: rgb(255, 255, 255, 0.30);
}

.chatlog-history-entry-time {
  display: block;
  font-size: 0.78rem;
  color: #8ea3c0;
  margin-bottom: 0.25rem;
}

.chatlog-history-entry-preview {
  display: block;
  font-size: 0.92rem;
  color: #e8f0ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Button styling inside input group */
.input-group-button .button {
  padding: 0.85em 1em;
  font-size: var(--font-size-lg);
  border-radius: 0 !important;
  cursor: pointer;
  height: 100%;
  margin-bottom: 0;
}

.input-group-button .button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Label styles */
.cell label {
  font-weight: bold;
  font-size: var(--font-size-md);
  margin-bottom: 0;
}

/* Input styles */
.cell input {
  padding: var(--spacing-sm);
  border: 1px solid #ccc;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-md);
  box-sizing: border-box;
  margin-bottom: 0;
}

/* Switch toggle styling */
.scale-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scale-toggle .switch-input {
  appearance: none;
  width: 50px;
  height: 25px;
  background-color: var(--button-bg);
  border-radius: 25px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background-color 0.3s ease;
}

.scale-toggle .switch-input:checked {
  background-color: #333;
}

.scale-toggle .switch-input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background-color: var(--text-color);
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.scale-toggle .switch-input:checked::before {
  transform: translateX(25px);
}

/* General container styles */
.grid-container {
  padding: 1.5rem;
}

/* Logo overlay styles */
.logo-overlay {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 30px;
  height: auto;
  pointer-events: none;
  z-index: 1;
}

.logo-overlay img {
  opacity: 60%;
  max-width: 100%;
  height: auto;
}

/* Grid styles */
.grid-x {
  display: flex;
  flex-wrap: wrap;
}

/* Censorship Styles */
.pixelated {
  filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='pixelate-filter'><feOffset dx='0' dy='0' result='box-blur'/><feFlood x='1' y='1' height='1' width='1'/><feComposite width='3' height='3'/><feTile result='tiles'/><feComposite in='box-blur' operator='in'/><feMorphology operator='dilate' radius='1'/></filter></svg>#pixelate-filter");
}

.hidden {
  opacity: 0;
}

.blur {
  filter: blur(4px);
}

/* Info tooltip styles */
.info-bracket {
  display: inline-block;
  align-items: center;
  justify-content: center;
  padding: 0.7em 1.2em;
  margin: 0 0 1rem 1rem;
  border-radius: var(--border-radius-md);
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: bold;
  border: 1px solid transparent;
  background-color: var(--button-bg);
  cursor: pointer;
  transition: background-color 0.25s ease-out, color 0.25s ease-out, transform 0.3s ease, box-shadow 0.3s ease;
  text-align: center;
  vertical-align: middle;
  line-height: 1;
  position: relative;
}

.info-bracket:hover {
  background-color: var(--button-bg-hover);
  box-shadow: 0 2px 10px var(--button-shadow);
  transform: translateY(-2px);
}

.info-bracket:focus {
  outline: 2px solid var(--text-color);
  outline-offset: 2px;
}

.info-icon {
  margin-right: 2px;
}

.tooltip-text {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #444;
  color: var(--text-color);
  padding: 8px;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 10;
  white-space: nowrap;
  min-width: 200px;
  text-align: left;
}

.info-bracket:hover .tooltip-text {
  display: block;
}

/* Censor character button styles */
.censor-char-button {
  padding: 0.85em 1em;
  font-weight: bold;
  font-size: var(--font-size-lg);
  line-height: 1;
}

/* Responsive styles */
@media only screen and (max-width: 768px) {
  .grid-container {
    padding: 1rem;
  }

  .textarea-input {
    font-size: var(--font-size-md);
    padding-left: 10px;
  }

  .button {
    font-size: var(--font-size-md);
  }
}
