/* =============================================================================
   GLOBAL STYLES
   ============================================================================= */

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

body {
  font-family: "Inter", sans-serif;
  background: #121212;
  color: #fff;
  padding: 20px;
  margin: 20px;
  background-color: #1e1e1e; 
  color: #f0f0f0; 
}

html {
  overflow-y: scroll;
}

/* Prevent text selection globally but ALLOW dragging */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* REMOVED: -webkit-user-drag: none; - This was blocking drag and drop! */
  -webkit-touch-callout: none;
}

/* Allow text selection for input fields */
input, textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* IMPORTANT: Allow drag and drop for draggable elements */
[draggable="true"] {
  -webkit-user-drag: element !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  cursor: grab !important;
}

[draggable="true"]:active {
  cursor: grabbing !important;
}

/* Additional specific overrides for tierlist elements */
.tierlist-perk-item[draggable="true"],
.tierlist-mini-perk[draggable="true"] {
  -webkit-user-drag: element !important;
  pointer-events: auto !important;
}

h1, h2 {
  color: #f0db4f;
}

h1 {
  text-align: center;
  margin-top: 100px; /* Adjust for top-left controls */
}

/* =============================================================================
   NAVIGATION STYLES
   ============================================================================= */

.top-nav {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 15px;
  align-items: center;
}

.nav-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #f0f0f0;
  background: #2a2a2a;
  padding: 10px;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.nav-icon:hover {
  transform: scale(1.05);
  background: #3a3a3a;
}

.nav-icon img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  margin-bottom: 5px;
}

.nav-icon span {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 3px;
}

.nav-progress-container {
  width: 50px;
  height: 8px;
  background-color: #1e1e1e;
  border: 1px solid #444;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.nav-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #8B0000, #DC143C, #B22222);
  transition: width 0.5s ease;
  border-radius: 3px;
}

.nav-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.8);
}

/* =============================================================================
   MAIN PROGRESS STYLES
   ============================================================================= */

.selected-area-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-progress-container {
  width: 400px;
  height: 25px;
  background-color: #1a1a1a;
  border: 2px solid #444;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.main-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #8BC34A, #CDDC39);
  transition: width 0.5s ease-in-out;
  border-radius: 10px;
}

.main-progress-text {
  position: absolute;
  width: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
  text-align: center;
}

/* =============================================================================
   HOME PAGE SPECIFIC STYLES
   ============================================================================= */

#container {
  display: flex;
  gap: 40px;
}

.column {
  flex: 1;
  background-color: #2a2a2a;
  padding: 10px;
  border-radius: 6px;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

.saved-character {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid #444;
  padding-bottom: 8px;
}

.saved-character img.char-icon {
  width: 80px;
  height: 80px;
  margin-right: 10px;
  border-radius: 8px;
  object-fit: contain;
}

.saved-perks img {
  width: 40px;
  height: 40px;
  margin-right: 5px;
}

.icon-navigation {
  display: flex;
  justify-content: center;
  gap: 60px;
  margin: 30px 0;
}

.icon-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #f0f0f0;
  transition: transform 0.2s ease;
}

.icon-link:hover {
  transform: scale(1.05);
  color: #f0db4f;
}

.icon-link img {
  width: 120px;
  height: 120px;
  margin-bottom: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.icon-link span {
  font-size: 18px;
  font-weight: bold;
}

.completion-counter {
  font-size: 16px;
  color: #bbb;
  margin-top: 5px;
  display: none; /* Hide the old text counter */
}

.progress-container {
  width: 120px;
  height: 25px;
  background-color: #2a2a2a;
  border: 2px solid #444;
  border-radius: 12px;
  margin-top: 8px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #8B0000, #DC143C, #B22222);
  transition: width 0.5s ease;
  border-radius: 10px;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  z-index: 10;
}

/* =============================================================================
   CHARACTER STYLES
   ============================================================================= */

.character-section {
  background: #2a2a2a;
  border-radius: 10px 10px 0 0;
  padding: 20px;
  margin: 120px 0 0 0; /* Add top margin to avoid controls overlap */
}

.character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #1e1e1e;
  border-radius: 8px;
  padding: 15px;
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
  height: 100px;
  box-sizing: border-box;
}

.character-card img {
  width: 80px;
  height: 80px;
  border: 2px solid transparent;
  outline: none;
  box-sizing: border-box;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.character-card img:hover {
  outline: 2px solid #f0db4f;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.character-card img.selected {
  outline: 2px solid dodgerblue;
}

.character-card img.locked {
  border-color: limegreen;
}

.character-name {
  margin-top: 4px;
  font-size: 0.85rem;
  text-align: center;
  color: #ddd;
}

/* =============================================================================
   PERK STYLES
   ============================================================================= */

#perk-selection-area {
  background: #2a2a2a;
  border-radius: 0 0 10px 10px;
  padding: 20px;
  margin: 0 0 20px 0;
}

#perk-selection-area h2, #perk-selection-area h3 {
  color: #f0db4f;
  text-align: center;
  margin: 0 0 0 0;
  font-size: 18px;
  background: #1e1e1e;
  border-radius: 8px 8px 0 0;
  padding: 15px;
}

#perk-selection-area h2 {
  margin: 20px 0 0 0;
}

.perk-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
  background: #1e1e1e;
  border-radius: 0 0 8px 8px;
  padding: 15px;
}

.perk-icon {
  width: 64px;
  height: 64px;
  cursor: pointer;
  border: 2px solid #666;
  border-radius: 6px;
  box-sizing: border-box;
  transition: all 0.2s ease;
  object-fit: cover;
}

.perk-icon:hover {
  border-color: #f0db4f;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.perk-slots {
  display: flex;
  gap: 10px;
  margin: 0 0 20px 0;
  background: #1e1e1e;
  border-radius: 0 0 8px 8px;
  padding: 15px;
}

.perk-slot {
  width: 80px;
  height: 80px;
  background: #333;
  border: 2px dashed #555;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.perk-slot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: none !important;
  border-radius: 4px;
  box-shadow: none !important;
  transform: none !important;
}

#available-perks div {
  position: relative;
  display: inline-block;
  margin: 4px;
}

/* =============================================================================
   SEARCH STYLES
   ============================================================================= */

#perk-selection-area .search-container {
  margin: 0 0 0 0;
  background: #1e1e1e;
  border-radius: 0 0 0 0;
  padding: 15px;
  text-align: center;
}

.search-container {
  margin: 15px 0;
}

.search-input {
  padding: 8px 12px;
  width: 300px;
  border: 2px solid #ccc;
  border-radius: 4px;
  font-size: 16px;
}

.search-input:focus {
  outline: none;
  border-color: dodgerblue;
}

/* =============================================================================
   RANDOM PERK BUTTON STYLES (from ui.js)
   ============================================================================= */

.random-perk-button {
  display: inline-block;
  width: 80px;
  height: 80px;
  border: 2px solid #666;
  border-radius: 8px;
  background-color: #2a2a2a;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 15px;
  vertical-align: top;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.random-perk-button:hover {
  border-color: #888;
  background-color: #3a3a3a;
  transform: scale(1.05);
}

.random-perk-button img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border: none !important;
  box-shadow: none !important;
  transform: none !important;
}

/* =============================================================================
   VIEW TOGGLE STYLES
   ============================================================================= */

.view-toggle-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.view-toggle-btn {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 10px;
  margin: 10px 5px 10px 0;
  font-size: 14px;
  font-weight: normal;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.view-toggle-btn:hover {
  background: #45a049;
}

/* =============================================================================
   TIERLIST STYLES
   ============================================================================= */

.tierlist-section {
  margin: 20px 0;
}

.character-perk-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #2a2a2a;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
  min-height: calc(100vh - 200px);
}

.character-column {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 15px;
  min-height: 60vh;
}

.character-column h3 {
  color: #f0db4f;
  text-align: center;
  margin: 0 0 15px 0;
  font-size: 18px;
}

.tierlist-character-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  /* Remove max-height and overflow to allow full page scrolling */
}

.tierlist-character-card {
  display: flex;
  align-items: center;
  background: #333;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.3s ease, transform 0.2s ease;
  border: 2px solid transparent;
  position: relative;
}

.tierlist-character-card:hover {
  background: #404040;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.tierlist-character-card.selected {
  border: 2px solid #4CAF50;
  background: #2a5a2a;
}

.tierlist-character-card.completed {
  border: 2px solid limegreen;
  background: #1a4a1a;
}

.tierlist-character-card img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
  margin-right: 12px;
}

.tierlist-character-info {
  flex: 1;
}

.tierlist-character-name {
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 4px;
}

.tierlist-character-perk-count {
  font-size: 12px;
  color: #ccc;
}

.tierlist-character-perks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  margin-top: 6px;
  width: 100%;
  max-width: 50px; /* Limit to fit within character info area */
}

.tierlist-mini-perk {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid #666;
  cursor: grab;
  transition: transform 0.2s ease;
  /* Ensure drag and drop works */
  -webkit-user-drag: element;
  -webkit-user-select: none;
  user-select: none;
}

.tierlist-mini-perk:hover {
  transform: scale(1.1);
}

.tierlist-mini-perk.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
  cursor: grabbing;
}

.perk-assignment-area {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 15px;
}

.perk-assignment-area h3 {
  color: #f0db4f;
  text-align: center;
  margin: 0 0 15px 0;
  font-size: 18px;
}

.tierlist-perk-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  /* Remove max-height and overflow to allow full page scrolling */
  min-height: 100px;
  border: 2px dashed transparent;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.tierlist-perk-list.drag-over {
  border-color: #4CAF50;
  background: rgba(76, 175, 80, 0.1);
}

.show-used-toggle {
  padding: 8px 12px;
  margin-left: 10px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  background: #4CAF50;
}

.show-used-toggle:hover {
  opacity: 0.9;
}

.tierlist-perk-item {
  position: relative;
  cursor: grab;
  transition: all 0.2s ease;
  border-radius: 6px;
  /* Ensure drag and drop works */
  -webkit-user-drag: element;
  -webkit-user-select: none;
  user-select: none;
}

.tierlist-perk-item:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.tierlist-perk-item.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
  cursor: grabbing;
}

.tierlist-perk-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid #666;
}

.tierlist-perk-item.used img {
  opacity: 0.6;
  border-color: #999;
}

.tierlist-character-card.drag-over {
  background: #4a4a4a;
  border-color: #4CAF50;
  box-shadow: inset 0 0 10px rgba(76, 175, 80, 0.5);
}

/* Responsive design for tierlist */
@media (max-width: 768px) {
  .character-perk-grid {
    gap: 15px;
    min-height: calc(100vh - 150px);
  }
  
  .character-column {
    min-height: 50vh;
  }
  
  .tierlist-character-list {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  .tierlist-character-card {
    flex-direction: column;
    text-align: center;
    min-width: 80px;
  }
  
  .tierlist-character-card img {
    margin-right: 0;
    margin-bottom: 5px;
  }
}

/* =============================================================================
   STREAMER TOOLS STYLES
   ============================================================================= */

.streamer-tools {
  max-width: 800px;
  margin: 40px auto;
  background: #2a2a2a;
  border-radius: 15px;
  padding: 30px;
  border: 2px solid #f0db4f;
}

.streamer-tools h2 {
  margin-top: 0;
}

.tool-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

.tool-button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 15px 25px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 180px;
}

.tool-button:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.setup-guide {
  background: #1e1e1e;
  border-radius: 10px;
  padding: 25px;
  border-left: 4px solid #f0db4f;
}

.setup-guide h3 {
  color: #f0db4f;
  margin-top: 0;
  margin-bottom: 20px;
}

.setup-guide ol {
  color: #f0f0f0;
  line-height: 1.8;
  padding-left: 20px;
}

.setup-guide li {
  margin-bottom: 10px;
}

.setup-guide strong {
  color: #4CAF50;
}

.setup-guide .note {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 15px;
  margin-top: 20px;
  color: #f0db4f;
}

.setup-guide .server-status {
  background: #1e2a1e;
  border: 1px solid #4CAF50;
  border-radius: 6px;
  padding: 15px;
  margin-top: 20px;
}

.setup-guide .server-status p {
  margin: 8px 0;
  color: #f0f0f0;
}

.setup-guide code {
  background: #1e1e1e;
  color: #4CAF50;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

.quick-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.quick-step {
  background: #1e1e1e;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 15px;
  text-align: center;
}

.quick-step strong {
  color: #4CAF50;
  font-size: 16px;
  display: block;
  margin-bottom: 5px;
}

.quick-step small {
  color: #ccc;
  line-height: 1.3;
}

.quick-step a {
  color: #4CAF50;
  text-decoration: none;
}

.quick-step a:hover {
  text-decoration: underline;
}

/* =============================================================================
   CONTROLS SECTION STYLES
   ============================================================================= */

#controls {
  position: absolute;
  top: 20px;
  left: 20px;
  background: #2a2a2a;
  border-radius: 12px;
  padding: 15px;
  border: 1px solid #444;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  z-index: 100;
  max-width: 600px;
  min-width: 200px;
  width: auto;
}

.settings-toggle {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
  width: 100%;
  justify-content: center;
}

.settings-toggle:hover {
  background: #45a049;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.settings-toggle.expanded {
  background: #FF9800;
  margin-bottom: 15px;
}

.settings-toggle.expanded:hover {
  background: #F57C00;
}

.controls-content {
  display: none;
  animation: slideDown 0.3s ease-in-out;
}

.controls-content.expanded {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    max-height: 500px;
    transform: translateY(0);
  }
}

.control-button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 4px 6px 4px 0;
  min-width: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.control-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.control-button.toggle-active {
  background: #FF9800;
}

.control-button.toggle-inactive {
  background: #666;
}

.control-button.danger {
  background: #f44336;
}

.control-button.danger:hover {
  background: #d32f2f;
}

.control-button.primary {
  background: #2196F3;
}

.control-button.primary:hover {
  background: #1976D2;
}

.control-button.purple {
  background: #9C27B0;
}

.control-button.purple:hover {
  background: #7B1FA2;
}

.control-button.success {
  background: #4CAF50;
}

.control-button.success:hover {
  background: #388E3C;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.controls-row:last-child {
  margin-bottom: 0;
}

.controls-label {
  font-weight: 600;
  color: #ccc;
  margin-right: 8px;
  min-width: 100px;
  font-size: 14px;
}

@media (max-width: 768px) {
  .tool-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .tool-button {
    width: 100%;
    max-width: 280px;
  }
  
  .quick-steps {
    grid-template-columns: 1fr;
  }
  
  #controls {
    position: static; /* Reset position on mobile */
    padding: 15px;
    margin: 20px 0;
    max-width: none;
    min-width: auto;
    width: 100%;
  }
  
  .settings-toggle {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  h1 {
    margin-top: 80px; /* Reset h1 margin on mobile */
  }
  
  .character-section {
    margin-top: 20px; /* Reset character section margin on mobile */
  }
  
  .controls-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .controls-label {
    min-width: auto;
    margin-bottom: 8px;
  }
}
