:root {
  --bg-color: #121212;
  --sidebar-bg: #1e1e1e;
  --card-bg: #252525;
  --text-main: #ffffff;
  --text-muted: #b3b3b3;
  --accent: #bb86fc;
  --accent-hover: #9959e0;
  --border: #333;
}

body.light-theme {
  --bg-color: #f4f4f9;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --text-main: #333;
  --text-muted: #666;
  --accent: #6200ee;
  --accent-hover: #3700b3;
  --border: #ddd;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', sans-serif;
}

body {
  background: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  height: 60px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo {
  font-weight: bold;
  font-size: 1.2rem;
  color: var(--accent);
}

.nav-controls button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  margin-left: 5px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 15px;
}

.list-header,
.grid {
  width: 100%;
  max-width: 1400px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#filterSelect {
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-main);
  cursor: pointer;
  height: 40px;
  width: 200px;
  font-weight: bold;
}

#filterSelect,
#searchInput,
#reorderBtn,
#saveOrderBtn,
#addCustomCharBtn {
  height: 40px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .header-controls {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }

  .navbar {
      padding: 0 10px;
  }

    .logo {
      font-weight: bold;
      font-size: 1rem;
      color: var(--accent);
    }

  #reorderBtn,
  #saveOrderBtn {
    width: 100% !important;
  }
}

#searchInput {
  height: 40px;
}

.container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

#listNav {
  list-style: none;
  overflow-y: auto;
}

#listNav li {
  padding: 10px;
  cursor: pointer;
  border-radius: 5px;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
}

#listNav li:hover,
#listNav li.active {
  background: var(--accent);
  color: white;
}

.delete-list-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}

.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.search-bar-container {
  position: relative;
  width: 300px;
}

#searchInput {
  width: 100%;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-main);
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  z-index: 500;
  max-height: 300px;
  overflow-y: auto;
}

.search-item {
  padding: 10px;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-item:hover {
  background: var(--border);
}

.search-item img {
  width: 40px;
  height: 60px;
  object-fit: cover;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  align-self: center;
}

#characterGrid {
  margin-bottom: 10px;
}


.char-card {
  background: var(--card-bg);
  border-radius: 8px;
  overflow: visible;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  position: relative;
  transition: transform 0.2s;
}

.char-card:hover {
  transform: translateY(-3px);
}

.char-img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.char-info {
  padding: 15px;
}

/* --- עיצוב חדש ואסתטי לציון --- */
.char-rating {
  position: absolute;
  top: 10px;
  right: 10px;

  /* רקע כהה חצי שקוף עם אפקט זכוכית */
  background: rgba(18, 18, 18, 0.80);
  backdrop-filter: blur(4px);

  /* טקסט בזהב ועיצוב גלולה */
  color: #FFD700;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 900;
  font-size: 0.9rem;

  /* מסגרת עדינה וצל נקי יותר */
  border: 1px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);

  /* יישור הטקסט והכוכב */
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 10;
}

/* .char-rating::before {
  content: "\f005";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.8rem;
  color: #FFD700;
} */

.char-name {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 5px;
}

.source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 2px;
}

.source-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 5px;
  margin-left: 5px;
  transition: transform 0.2s;
}

.icon-btn:hover {
  transform: scale(1.2);
}

.delete-btn {
  color: #ff5555;
}

.edit-btn {
  color: #55aaff;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

#listModalTitle {
  margin-bottom: 10px;
}

#saveListBtn {
  margin-top: 20px;
}


.modal-content {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.small-modal {
  max-width: 350px;
  text-align: center;
  z-index: 2010;
}

#authTitle {
  margin-bottom: 13px;
}

.close-modal {
  position: absolute;
  top: 5px;
  right: 15px;
  font-size: 30px;
  cursor: pointer;
  z-index: 2005;
  color: var(--text-main);
  border: none;
  background: transparent;
}

.modal-body {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  flex-wrap: wrap;
}

#modalImg {
  width: 150px;
  height: 220px;
  border-radius: 5px;
  object-fit: cover;
}

.modal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 250px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  margin-bottom: 10px;
}

input {
  padding: 8px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 100%;
}

.btn-primary {
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  width: 100%;
}

.row-group {
  display: flex;
  gap: 10px;
  width: 100%;
}

select {
  padding: 8px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 100%;
  border-radius: 4px;
  cursor: pointer;
}

.cast-grid {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 0;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.cast-grid img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s;
}

.cast-grid img:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}


.mobile-only,
.mobile-overlay {
  display: none;
}

#createListBtn {
  background: var(--accent);
  /* צבע הסגול/ראשי של האתר */
  color: white;
  border: none;
  border-radius: 50%;
  /* עושה אותו עגול לגמרי */
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  padding: 0;
}

#createListBtn:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

#createListBtn i {
  margin: 0;
}

@media (max-width: 768px) {

  .mobile-only {
    display: block;
    color: var(--text-main);
    font-size: 1.2rem;
  }

  .nav-controls #shareBtn {
    font-size: 0.7rem;
  }

  #userDisplay {
    display: none;
  }

  .container {
    position: relative;
  }


  .sidebar {
    position: fixed;
    top: 60px;
    left: -260px;
    width: 250px;
    height: calc(100vh - 60px);
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    left: 0;
  }

  .mobile-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
    backdrop-filter: blur(2px);
  }

  .mobile-overlay.active {
    display: block;
  }

  .list-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-controls {
    flex-direction: column;
    width: 100%;
  }

  #filterSelect,
  .search-bar-container {
    width: 100%;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }

  .char-img {
    height: 200px;
  }


  .modal-content {
    width: 95%;
    max-height: 85vh;
    padding: 15px;
  }

  .modal-body {
    flex-direction: column;
    align-items: center;
  }

  #modalImg {
    width: 120px;
    height: 180px;
  }

  .row-group {
    flex-direction: column;
  }

  #themeToggle {
  display: none;
}
}

#deleteModal .btn-primary {
  width: auto;
  padding: 10px 20px;
}

.modal-content .btn-primary {
  width: auto;
  padding: 10px 20px;
}

.rank-badge {
  position: absolute;
  top: -15px;
  left: -15px;
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 900;
  font-size: 1.4rem;
  color: #000;
  border-radius: 50%;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.6);
  z-index: 100;
  border: 3px solid #fff;
}

.rank-1 {
  background: linear-gradient(135deg, #FFD700, #ffaa00);
  transform: scale(1.1);
  z-index: 101;
}

.rank-2 {
  background: linear-gradient(135deg, #E0E0E0, #BDBDBD);
}

.rank-3 {
  background: linear-gradient(135deg, #f0a263, #A0522D);
}

@media (max-width: 1200px) {

  .rank-1,
  .rank-2,
  .rank-3 {
    border: 2px solid #555;
    font-size: 1rem;
    width: 40px;
    height: 40px;
    top: -10px;
    left: -10px;
  }
}

.rank-other {
  background: #333;
  color: #fff;
  border: 2px solid #555;
  font-size: 1rem;
  width: 40px;
  height: 40px;
  top: -10px;
  left: -10px;
}

.reorder-mode .char-card {
  cursor: grab;
  border: 2px dashed var(--accent);
  transform: scale(0.95);
  opacity: 0.9;
}

.reorder-mode .char-card:hover {
  background-color: var(--sidebar-bg);
}

.reorder-mode .card-actions {
  display: none;
}

.dragging {
  opacity: 0.5;
  border-color: #fff;
}

.user-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s;
  position: relative;
  max-width: 100%;
  overflow: hidden;
}

.user-card div {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 5px;
}

.user-card:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-3px);
}

.user-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.user-card:hover .user-icon {
  color: white;
}

.comm-list-card {
  background: var(--card-bg);
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  text-align: center;
}

.comm-list-card:hover {
  border-color: var(--accent);
}

.follow-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 1.2rem;
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  transition: transform 0.2s;
}

.follow-btn:hover {
  transform: scale(1.2);
}

.follow-btn i.active {
  color: #ffd700 !important;
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}


.active-tab {
  background-color: var(--accent) !important;
  color: white !important;
}

.inactive-tab {
  background-color: #333 !important;
  color: #b3b3b3 !important;
  border: 1px solid var(--border);
}