@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0f1115;
  --panel: #161a22;
  --muted: #6b7280;
  --text: #e5e7eb;
  --accent: #22d3ee;
  --accent-2: #f97316;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 16px;
  --primary-gradient: linear-gradient(135deg, #00c6ff, #0072ff);
  --danger-gradient: linear-gradient(135deg, #ff416c, #ff4b2b);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", system-ui, sans-serif;
  min-height: 100vh;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Topnav */
.topnav {
  position: sticky;
  top: 10px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: rgba(22, 26, 34, 0.85);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.logo {
  font-size: 24px;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  user-select: none;
}

.logo:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.logo:active {
  transform: scale(0.98);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.username {
  font-weight: 600;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  color: #fff;
  font-family: 'Inter', sans-serif;
}

.btn-login {
  background: var(--primary-gradient);
}

.btn-logout {
  background: var(--danger-gradient);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 198, 255, 0.4);
}

.btn-logout:hover {
  box-shadow: 0 4px 15px rgba(255, 65, 108, 0.4);
}

/* Toolbar */
.toolbar {
  background: var(--panel);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.toolbar-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 15px;
}

.filter-group,
.action-group {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.combobox,
.search-input {
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0b0f17;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.combobox:focus,
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}

.search-input {
  width: 250px;
}

.btn-bookmark-mgr {
  background: #2b3445;
  color: #dbe7ff;
}

.btn-bookmark-mgr:hover {
  background: #3a455a;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.btn-add {
  background: linear-gradient(135deg, #11998e, #38ef7d);
}

.btn-add:hover {
  box-shadow: 0 4px 15px rgba(56, 239, 125, 0.4);
}

.toolbar-bottom {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-bookmark-item {
  padding: 6px 14px;
  background: rgba(34, 211, 238, 0.1);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-bookmark-item:hover,
.btn-bookmark-item.active {
  background: var(--accent);
  color: #000;
  box-shadow: 0 4px 10px rgba(34, 211, 238, 0.4);
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

/* Card */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  border-color: rgba(34, 211, 238, 0.4);
}

.poster {
  position: relative;
  aspect-ratio: 3/4;
  background: #0c0f15;
  overflow: hidden;
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card:hover .poster img {
  transform: scale(1.1);
}

.poster::after {
  content: "";
  position: absolute;
  inset: 0;
  /* background: linear-gradient(0deg, rgba(22,26,34,1) 0%, rgba(22,26,34,0.3) 50%, transparent 100%); */
}

.card.has-new {
  border-color: rgba(56, 239, 125, 0.6);
  box-shadow: 0 4px 20px rgba(56, 239, 125, 0.15);
}

.card.has-new:hover {
  border-color: rgba(56, 239, 125, 1);
  box-shadow: 0 15px 40px rgba(56, 239, 125, 0.3);
}

.badge-priority {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: #ffde00;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(255, 222, 0, 0.3);
  z-index: 2;
  transition: all 0.2s ease;
}

.badge-priority:hover {
  transform: scale(1.08);
  background: rgba(255, 222, 0, 0.15);
  border-color: rgba(255, 222, 0, 0.8);
  box-shadow: 0 0 12px rgba(255, 222, 0, 0.4);
}

.badge-unwatched {
  position: absolute;
  top: 12px;
  left: 12px;
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  color: #fff;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  z-index: 2;
  box-shadow: 0 4px 15px rgba(255, 65, 108, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 4px 15px rgba(255, 65, 108, 0.4);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 4px 25px rgba(255, 65, 108, 0.7);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 4px 15px rgba(255, 65, 108, 0.4);
  }
}

.badge-episodes {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: var(--primary-gradient);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 4px 15px rgba(0, 198, 255, 0.4);
  transition: all 0.2s ease;
}

.badge-episodes:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 198, 255, 0.7);
  filter: brightness(1.1);
}

.quick-action-menu {
  position: absolute;
  bottom: 45px;
  left: 12px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px) scale(0.8);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 10;
}

.quick-action-menu.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.btn-qa {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  color: white;
  font-weight: bold;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, filter 0.2s;
}

.btn-qa:hover {
  transform: scale(1.1);
  filter: brightness(1.2);
}

.btn-qa.qa-lvl-minus,
.btn-qa.qa-lvl-plus {
  background: linear-gradient(135deg, #8E2DE2, #4A00E0);
}

.btn-qa.qa-ep-minus,
.btn-qa.qa-ep-plus {
  background: linear-gradient(135deg, #11998e, #38ef7d);
}

.info {
  padding: 16px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 2;
  background: var(--panel);
}

.name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s ease;
}

.info-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card:hover .name {
  color: var(--accent);
}

/* Prevent title cyan highlight when hovering over separate interactive elements */
.card:has(.badge-priority:hover) .name,
.card:has(.badge-episodes:hover) .name,
.card:has(.quick-action-menu:hover) .name {
  color: #fff !important;
}


.descr {
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-edit,
.btn-delete {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  font-family: inherit;
}

.btn-edit {
  background: rgba(34, 211, 238, 0.15);
  color: var(--accent);
}

.btn-edit:hover {
  background: var(--accent);
  color: #000;
}

.btn-delete {
  background: rgba(255, 65, 108, 0.15);
  color: #ff416c;
}

.btn-delete:hover {
  background: #ff416c;
  color: #fff;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--panel);
  width: 90%;
  max-width: 650px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  animation: scaleIn 0.3s ease forwards;
}

@keyframes scaleIn {
  to {
    transform: scale(1);
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: #fff;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0;
  line-height: 1;
}

.btn-close:hover {
  color: var(--accent-2);
}

.modal-body {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 13px;
  color: #aab1bf;
  font-weight: 600;
}

.form-control {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0b0f17;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-group input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-group label {
  cursor: pointer;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.1);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-save {
  background: var(--primary-gradient);
}

/* Bookmark Styles */
.bookmark-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  overflow: hidden;
}

.bookmark-table th,
.bookmark-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}

.bookmark-table th {
  background: rgba(0, 0, 0, 0.3);
  font-weight: 600;
  color: #aab1bf;
}

.bookmark-table td a {
  color: #22d3ee;
  text-decoration: none;
  word-break: break-all;
}

.bookmark-table td a:hover {
  text-decoration: underline;
}

.bookmark-table tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sm-edit {
  background: rgba(34, 211, 238, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.btn-sm-edit:hover {
  background: #22d3ee;
  color: #0c0f15;
}

.btn-sm-delete {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  margin-left: 8px;
}

.btn-sm-delete:hover {
  background: #ef4444;
  color: white;
}

/* Schedule Days Indicators */
.schedule-days {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.day-dot {
  flex: 1;
  text-align: center;
  padding: 4px 0;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

.day-dot.active {
  color: #fff;
  background: var(--primary-gradient);
  border-color: rgba(0, 198, 255, 0.4);
  box-shadow: 0 0 8px rgba(0, 114, 255, 0.4);
}

.day-dot.is-today {
  border: 1px dashed rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.day-dot.active.is-today {
  border-color: #ff9f43;
  background: linear-gradient(135deg, #ff9f43, #ff5252);
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 82, 82, 0.6);
  animation: today-pulse 2s infinite;
}

@keyframes today-pulse {
  0% {
    box-shadow: 0 0 8px rgba(255, 82, 82, 0.5);
  }
  50% {
    box-shadow: 0 0 16px rgba(255, 82, 82, 0.9);
  }
  100% {
    box-shadow: 0 0 8px rgba(255, 82, 82, 0.5);
  }
}

/* Today Date Header Indicator */
.today-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Global Processing Loading Modal */
.processing-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 17, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.processing-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.processing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  background: rgba(22, 26, 34, 0.85);
  padding: 30px 40px;
  border-radius: var(--radius);
  border: 1px solid rgba(34, 211, 238, 0.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(34, 211, 238, 0.1);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.processing-modal.active .processing-content {
  transform: scale(1);
}

.processing-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 255, 255, 0.05);
  border-top: 4px solid var(--accent);
  border-right: 4px solid rgba(34, 211, 238, 0.3);
  border-radius: 50%;
  animation: processing-spin 1s cubic-bezier(0.53, 0.21, 0.29, 0.67) infinite;
  box-shadow: 0 0 15px rgba(34, 211, 238, 0.15);
}

@keyframes processing-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.processing-text {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.processing-dots span {
  display: inline-block;
  animation: processing-blink 1.4s infinite both;
  font-size: 18px;
  line-height: 0;
}

.processing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.processing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes processing-blink {
  0% {
    opacity: 0.2;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

/* Responsive for Topnav on Mobile */
@media (max-width: 600px) {
  .topnav {
    flex-direction: column;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    text-align: center;
    top: 5px;
  }

  .brand-container {
    width: 100%;
    justify-content: center !important;
    gap: 12px !important;
    flex-wrap: wrap;
  }

  .user-actions {
    width: 100%;
    justify-content: center;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
  }

  .today-date {
    font-size: 12px;
    padding: 4px 12px;
  }

  .logo {
    font-size: 22px;
  }
}