:root {
  --bg-color: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --secondary-color: #10b981;
  --danger-color: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(148, 163, 184, 0.1);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Kanit", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Header */
header {
  grid-column: 1 / -1;
  text-align: center;
  margin-bottom: 1rem;
  padding: 2rem;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: var(--glass-border);
  box-shadow: var(--shadow-lg);
}

header h1 {
  font-size: 2.5rem;
  background: linear-gradient(to right, #60a5fa, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  letter-spacing: -0.025em;
}

/* Sections */
section {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: var(--glass-border);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.add-gift-section {
  position: sticky;
  top: 2rem;
}

h2 {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: var(--glass-border);
  font-weight: 600;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Bot Status Toggle */
.bot-status-container {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 20px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  margin-top: 1rem;
  display: inline-flex; /* Center in header */
}

.status-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 1px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
  margin-bottom: 0; /* Override label margin */
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(145deg, #333, #222);
  transition: 0.4s;
  border-radius: 34px;
  box-shadow:
    inset 2px 2px 5px rgba(0, 0, 0, 0.5),
    inset -2px -2px 5px rgba(255, 255, 255, 0.05);
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: #888;
  transition: 0.4s;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input:checked + .slider {
  background: linear-gradient(145deg, #10b981, #059669);
}

input:checked + .slider:before {
  transform: translateX(30px);
  background-color: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-hover)
  );
  color: white;
  flex: 1;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.btn.primary:hover {
  filter: brightness(1.1);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn.edit {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.btn.edit:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn.test {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.btn.test:hover {
  background: rgba(59, 130, 246, 0.25);
}

/* Gift Grid */
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.gift-card {
  background: rgba(30, 41, 59, 0.4);
  border: var(--glass-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.gift-card:hover {
  transform: translateY(-4px);
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: var(--shadow-lg);
}

.gift-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.gift-media {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gift-media img {
  transition: transform 0.2s;
}

.gift-media img:hover {
  transform: scale(1.1);
}

.gift-info {
  flex: 1;
  min-width: 0;
}

.gift-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gift-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.gift-commands {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 6px;
  padding: 0.75rem;
  font-family: "Fira Code", monospace;
  font-size: 0.85rem;
  color: #e2e8f0;
  margin-bottom: 1rem;
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.command-line {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  word-break: break-all;
  line-height: 1.4;
}

.command-line:last-child {
  border-bottom: none;
}

.gift-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.gift-actions .btn {
  padding: 0.5rem;
  font-size: 0.85rem;
}

/* Image Preview */
.image-preview {
  margin-top: 0.75rem;
  width: 100%;
  height: 150px;
  border-radius: 8px;
  border: 2px dashed rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.3);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Session Management */
.session-section {
  grid-column: 1 / -1;
}

.session-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.session-form input {
  flex: 1;
  min-width: 180px;
}

.session-form .btn {
  white-space: nowrap;
  flex: 0 0 auto;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.session-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 10px;
  border: 2px dashed rgba(148, 163, 184, 0.15);
}

.session-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: all 0.25s ease;
}

.session-card.active {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.06);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.08);
}

.session-card:hover {
  background: rgba(30, 41, 59, 0.6);
}

.session-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.session-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}

.session-status-dot.online {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulse-green 2s infinite;
}

.session-status-dot.offline {
  background: #475569;
}

@keyframes pulse-green {
  0%,
  100% {
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
  }
}

.session-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.session-tiktok {
  font-weight: 600;
  color: #e0e7ff;
}

.session-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.session-player {
  font-weight: 600;
  color: #a7f3d0;
}

.session-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn.small {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  flex: 0;
}

/* Responsive */
@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }

  .add-gift-section {
    position: static;
  }
}

/* Custom Select */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 100%;
}

.custom-select {
  position: relative;
  display: flex;
  flex-direction: column;
}

.custom-select__trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-select__trigger:hover {
  border-color: var(--primary-color);
}

.custom-options {
  position: absolute;
  display: block;
  top: 100%;
  left: 0;
  right: 0;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-top: 0;
  background: #1e293b;
  transition: all 0.3s;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.custom-select.open .custom-options {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  margin-top: 5px;
}

.custom-option {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.custom-option:last-child {
  border-bottom: none;
}

.custom-option:hover {
  background-color: rgba(59, 130, 246, 0.2);
  color: white;
}

.custom-option.selected {
  background-color: rgba(59, 130, 246, 0.4);
  color: white;
}

.custom-option img {
  width: 24px;
  height: 24px;
  margin-right: 10px;
  object-fit: contain;
  border-radius: 50%;
}

.arrow {
  position: relative;
  height: 10px;
  width: 10px;
}

.arrow::before,
.arrow::after {
  content: "";
  position: absolute;
  bottom: 0px;
  width: 0.15rem;
  height: 100%;
  transition: all 0.3s;
}

.arrow::before {
  left: -3px;
  transform: rotate(-45deg);
  background-color: var(--text-muted);
}

.arrow::after {
  left: 3px;
  transform: rotate(45deg);
  background-color: var(--text-muted);
}

.custom-select.open .arrow::before {
  left: -3px;
  transform: rotate(45deg);
}

.custom-select.open .arrow::after {
  left: 3px;
  transform: rotate(-45deg);
}
