:root {
  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #1e222b;
  --surface-3: #262b36;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --primary: #7c5cff;
  --primary-hover: #6a49f2;
  --danger: #ff6b6b;
  --success: #2ecc71;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.error { color: var(--danger); font-size: 0.85rem; }
.full { grid-column: 1 / -1; }

/* ---- Botões ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; font-size: 0.9rem; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #303644; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 9px; font-size: 0.8rem; }
.btn i { width: 16px; height: 16px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.login-logo { width: 72px; margin: 0 auto 8px; }
.login-card h1 { font-size: 1.3rem; margin: 0; text-align: center; }
.login-card p.muted { text-align: center; margin: 0 0 8px; }

/* ---- Inputs ---- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; }
label > span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; color: var(--text);
  font-size: 0.95rem; font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.field-label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }

/* ---- Layout c/ sidebar ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 10px 8px 22px; }
.sidebar-brand img { height: 38px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: none; color: var(--muted);
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  font-size: 0.92rem; text-align: left; width: 100%; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { width: 18px; height: 18px; }
.nav-logout { color: var(--danger); margin-top: auto; }
.nav-logout:hover { background: rgba(255, 107, 107, 0.1); color: var(--danger); }

.content { flex: 1; padding: 28px 34px; max-width: 1100px; }
.section { display: none; }
.section.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-head h1 { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; margin: 0; }
.section-head h1 i { width: 24px; height: 24px; color: var(--primary); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

/* ---- Grupos (checkbox) ---- */
.groups-box {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px; max-height: 260px; overflow: auto;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2);
}
.group-item { flex-direction: row; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 8px; cursor: pointer; }
.group-item:hover { background: var(--surface-3); }
.group-item input { width: auto; }
.group-item span { color: var(--text); flex: 1; }

/* ---- Dias da semana ---- */
.weekdays { display: flex; flex-wrap: wrap; gap: 8px; }
.weekdays label { flex-direction: row; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); padding: 8px 12px; border-radius: 9px; cursor: pointer; color: var(--text); }
.weekdays input { width: auto; }

/* ---- Preview de mídia ---- */
.media-preview img, .media-preview video { max-width: 260px; max-height: 200px; border-radius: 10px; display: block; margin-top: 6px; }
.media-preview audio { margin-top: 6px; width: 100%; max-width: 320px; }

/* ---- Tabela ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--muted); font-weight: 500; }

/* ---- Galeria de mídias ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 1; display: grid; place-items: center; background: #0c0e12; overflow: hidden; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb audio { width: 92%; }
.media-thumb .filelink { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.media-meta { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; }

/* ---- Schedules ---- */
.schedule-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border); }
.schedule-row:first-child { border-top: none; }
.schedule-info { display: flex; gap: 14px; align-items: flex-start; }
.schedule-media img, .schedule-media video { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }
.schedule-media audio { width: 200px; }
.schedule-actions { display: flex; gap: 6px; }
.snippet { margin-top: 5px; color: var(--text); font-size: 0.9rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.72rem; margin-left: 6px; vertical-align: middle; }
.badge-pending { background: #3a3512; color: #e8c84d; }
.badge-active { background: #12303a; color: #4dd0e8; }
.badge-sent { background: #123a1f; color: var(--success); }
.badge-failed { background: #3a1212; color: var(--danger); }
.badge-canceled { background: var(--surface-3); color: var(--muted); }
.schedule-info .muted i { width: 14px; height: 14px; vertical-align: -2px; }

/* ---- Toast ---- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar .nav-item span, .sidebar-brand img { display: none; }
  .content { padding: 20px 16px; }
}
