/* ========================================
   SORTEIO INSTA — Design System
   ======================================== */

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

:root {
  --ig-purple:    #7C3AED;
  --ig-pink:      #EC4899;
  --ig-orange:    #F97316;
  --ig-grad:      linear-gradient(135deg, #7C3AED 0%, #EC4899 50%, #F97316 100%);
  --ig-grad-soft: linear-gradient(135deg, #7C3AED22 0%, #EC489922 50%, #F9731622 100%);

  --bg:           #0D0D0F;
  --bg-card:      #16161A;
  --bg-card2:     #1E1E24;
  --border:       #2A2A35;
  --border-glow:  rgba(124, 58, 237, 0.4);

  --text:         #F4F4F6;
  --text-muted:   #8888A0;
  --text-dim:     #555568;

  --success:      #22C55E;
  --warning:      #FBBF24;
  --error:        #EF4444;
  --info:         #38BDF8;

  --radius:       14px;
  --radius-sm:    8px;
  --radius-lg:    20px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 32px rgba(124,58,237,0.25);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── LAYOUT ── */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 36px 40px;
  max-width: calc(100vw - 260px);
}

/* ── LOGO ── */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 40px; height: 40px;
  background: var(--ig-grad);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.logo-text { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.logo-text span { background: var(--ig-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* ── NAV ── */
.nav-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); padding: 0 12px; margin-bottom: 8px; }
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-bottom: 24px; }
.nav-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  transition: all 0.2s;
  position: relative;
}
.nav-list a:hover, .nav-list a.active {
  background: var(--ig-grad-soft);
  color: var(--text);
}
.nav-list a.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 99px;
  background: var(--ig-grad);
}
.nav-list a .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-badge { margin-left: auto; font-size: 0.7rem; background: var(--ig-purple); color: #fff; padding: 1px 7px; border-radius: 99px; }

.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); }
.sidebar-footer a { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.85rem; text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); transition: all 0.2s; }
.sidebar-footer a:hover { color: var(--text); background: var(--bg-card2); }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 32px; }
.page-header h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700; margin-bottom: 6px; }
.page-header p { color: var(--text-muted); font-size: 0.95rem; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 12px; }
.breadcrumb span { color: var(--ig-pink); }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.card-glow { box-shadow: var(--shadow-glow), var(--shadow); border-color: var(--border-glow); }
.card-title { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ── STAT CARDS ── */
.stat-card { text-align: center; padding: 28px 20px; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 2.2rem; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); }
.stat-icon { font-size: 1.8rem; margin-bottom: 12px; display: block; }
.stat-purple .stat-value { background: linear-gradient(135deg, var(--ig-purple), var(--ig-pink)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-green .stat-value { color: var(--success); }
.stat-yellow .stat-value { color: var(--warning); }
.stat-blue .stat-value { color: var(--info); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 0.9rem; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary {
  background: var(--ig-grad);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,58,237,0.45); }
.btn-secondary { background: var(--bg-card2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--ig-purple); color: var(--ig-purple); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-card2); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--error); color: #fff; }
.btn-success { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── FORMS ── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.form-label span { color: var(--error); }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  transition: all 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--ig-purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}
.form-input::placeholder { color: var(--text-dim); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888A0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.form-textarea { resize: vertical; min-height: 100px; }
.input-group { display: flex; gap: 0; }
.input-group .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: nowrap; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ig-purple); cursor: pointer; }
.form-check label { font-size: 0.88rem; color: var(--text); cursor: pointer; }

/* ── ALERTS ── */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); display: flex; align-items: flex-start; gap: 12px; font-size: 0.88rem; margin-bottom: 20px; }
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-warning { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: #fde68a; }
.alert-info { background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.3); color: #bae6fd; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-purple { background: rgba(124,58,237,0.2); color: #c4b5fd; border: 1px solid rgba(124,58,237,0.3); }
.badge-green { background: rgba(34,197,94,0.2); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.badge-yellow { background: rgba(251,191,36,0.2); color: #fde68a; border: 1px solid rgba(251,191,36,0.3); }
.badge-red { background: rgba(239,68,68,0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.badge-gray { background: rgba(136,136,160,0.15); color: var(--text-muted); border: 1px solid var(--border); }
.badge-blue { background: rgba(56,189,248,0.15); color: #7dd3fc; border: 1px solid rgba(56,189,248,0.3); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th { padding: 10px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card2); }
tbody td { padding: 14px 16px; color: var(--text); vertical-align: middle; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.avatar-placeholder { width: 36px; height: 36px; border-radius: 50%; background: var(--ig-grad); display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; color: #fff; flex-shrink: 0; }

/* ── SPINNER / LOADING ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
@keyframes gradient-shift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--ig-purple); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.loading-text { animation: pulse 1.5s ease-in-out infinite; }

/* ── WINNER CARD ── */
.winner-wrap { position: relative; }
.winner-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-glow), var(--shadow);
  position: relative; overflow: hidden;
}
.winner-card::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--ig-grad-soft);
  pointer-events: none;
}
.winner-avatar-wrap { position: relative; display: inline-block; margin-bottom: 20px; }
.winner-avatar { width: 100px; height: 100px; border-radius: 50%; border: 4px solid transparent; background: var(--ig-grad) border-box; position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; font-weight: 800; color: #fff; overflow: hidden; }
.winner-avatar img { width: 100%; height: 100%; object-fit: cover; }
.winner-ring {
  position: absolute; inset: -6px;
  border-radius: 50%;
  background: var(--ig-grad);
  animation: spin 3s linear infinite;
  z-index: 0;
}
.winner-ring::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--bg-card); }
.winner-name { font-family: 'Space Grotesk', sans-serif; font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.winner-comment { font-size: 0.9rem; color: var(--text-muted); max-width: 340px; margin: 0 auto 20px; }
.winner-confetti { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }

/* ── RAFFLE MACHINE ── */
.raffle-machine {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  min-height: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.raffle-drum {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--ig-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(124,58,237,0.4);
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}
.raffle-drum:hover { transform: scale(1.05); }
.raffle-drum.rolling {
  animation: spin 0.5s linear infinite;
}
.raffle-names-scroll {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem; font-weight: 600;
  color: var(--text-muted);
  min-height: 32px;
  transition: all 0.1s;
}
.raffle-names-scroll.rolling { animation: pulse 0.3s ease-in-out infinite; color: var(--ig-pink); }

/* ── PROGRESS ── */
.progress { background: var(--bg-card2); border-radius: 99px; height: 8px; overflow: hidden; margin: 8px 0; }
.progress-bar { height: 100%; background: var(--ig-grad); border-radius: 99px; transition: width 0.4s ease; background-size: 200% 200%; animation: gradient-shift 2s ease infinite; }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; background: var(--bg-card2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 24px; width: fit-content; }
.tab { padding: 8px 18px; border-radius: 6px; font-size: 0.88rem; font-weight: 500; cursor: pointer; color: var(--text-muted); transition: all 0.2s; border: none; background: none; }
.tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* ── TOGGLE ── */
.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-card2); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; left: 3px; bottom: 3px; width: 18px; height: 18px; background: var(--text-muted); border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .toggle-slider { background: var(--ig-purple); border-color: var(--ig-purple); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px; max-width: 520px; width: 100%;
  transform: scale(0.95); transition: transform 0.2s;
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; padding: 4px; border-radius: var(--radius-sm); transition: all 0.2s; line-height: 1; }
.modal-close:hover { color: var(--text); background: var(--bg-card2); }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 3.5rem; margin-bottom: 16px; }
.empty-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.empty-text { color: var(--text-muted); font-size: 0.9rem; max-width: 320px; margin: 0 auto 24px; }

/* ── TOAST ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); min-width: 260px; max-width: 380px;
  font-size: 0.88rem; pointer-events: all;
  transform: translateX(110%); transition: transform 0.3s ease;
}
.toast.show { transform: translateX(0); }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-info { border-left: 3px solid var(--ig-purple); }

/* ── INSTAGRAM CONNECT ── */
.ig-connect-box {
  background: var(--ig-grad-soft);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
}
.ig-connect-icon { font-size: 4rem; margin-bottom: 16px; }
.ig-connect-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.ig-connect-text { color: var(--text-muted); font-size: 0.9rem; max-width: 380px; margin: 0 auto 28px; }

/* ── COMMENT ITEM ── */
.comment-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }
.comment-body { flex: 1; }
.comment-user { font-weight: 600; font-size: 0.88rem; display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.comment-text { font-size: 0.88rem; color: var(--text-muted); }
.comment-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.comment-item.winner-highlight { background: rgba(124,58,237,0.08); margin: 0 -14px; padding: 14px; border-radius: var(--radius-sm); border-bottom: none; }

/* ── MOBILE HAMBURGER ── */
.hamburger { display: none; position: fixed; top: 16px; left: 16px; z-index: 200; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; font-size: 1.2rem; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .main-content { margin-left: 0; padding: 24px 20px; padding-top: 64px; max-width: 100vw; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── GRADIENT TEXT UTIL ── */
.grad-text { background: var(--ig-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.fw-600 { font-weight: 600; }
.w-full { width: 100%; }
