/* ======================================================
   Hub42 - Estilos do painel admin
   ====================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0d;
  --bg2:       #151515;
  --card-bg:   #1e1e1e;
  --border:    #2e2e2e;
  --text:      #e8e8e8;
  --muted:     #888;
  --accent:    #e05533;
  --success:   #27ae60;
  --danger:    #c0392b;
  --warning:   #f39c12;
  --info:      #2980b9;

  --sidebar-w: 230px;
  --topbar-h:  56px;
  --radius:    8px;

  --yt:   #FF0000;
  --ig:   #E1306C;
  --fb:   #1877F2;
  --tt:   #69C9D0;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
svg { display: inline-block; vertical-align: middle; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 28px;
}

.login-box .form-group label {
  color: #aaaaaa;
  font-size: 0.78rem;
}

.back-link {
  margin-top: 20px;
  font-size: 0.83rem;
  color: var(--muted);
  text-align: center;
}

.back-link a { color: #5b9cf6; }
.back-link a:hover { text-decoration: underline; }

.btn-full {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-full:hover { background: #c04828; }

/* ============================================================
   LAYOUT ADMIN
   ============================================================ */

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s;
}

.sidebar-brand {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand a {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  border-right: 3px solid transparent;
}

.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.sidebar-nav a.active { color: var(--text); background: rgba(255,255,255,0.06); border-right-color: var(--accent); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

.sidebar-footer a { color: var(--muted); transition: color 0.15s; }
.sidebar-footer a:hover { color: var(--text); }

/* Wrap do conteúdo */
.admin-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.admin-topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: none;
  padding: 4px;
}

.topbar-title {
  font-weight: 600;
  font-size: 0.92rem;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.83rem;
}

.topbar-user { color: var(--muted); }
.topbar-logout { color: #5b9cf6; }
.topbar-logout:hover { text-decoration: underline; }

/* Main */
.admin-main {
  padding: 28px 28px 60px;
  flex: 1;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Alertas */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-success { background: rgba(39,174,96,0.15); border: 1px solid rgba(39,174,96,0.4); color: #6fcf97; }
.alert-error   { background: rgba(192,57,43,0.15); border: 1px solid rgba(192,57,43,0.4); color: #eb5757; }
.alert-warning { background: rgba(243,156,18,0.15); border: 1px solid rgba(243,156,18,0.4); color: #f2994a; }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Buttons */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 9px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-primary:hover { background: #c04828; }

.btn-outline {
  display: inline-block;
  background: transparent;
  color: var(--text);
  padding: 9px 20px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
}

.btn-outline:hover { border-color: #555; }

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit; text-decoration: none;
}

.btn-action:hover { border-color: #555; background: #252525; }
.btn-action svg   { width: 16px; height: 16px; }

.btn-yt   { border-color: #FF0000 !important; color: #FF0000; }
.btn-yt:hover { background: rgba(255,0,0,0.1) !important; }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat-card .stat-icon { width: 28px; height: 28px; margin: 0 auto 8px; }
.stat-card .stat-num  { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.stat-card.plat-youtube   { border-top: 3px solid var(--yt); }
.stat-card.plat-youtube   .stat-icon { color: var(--yt); }
.stat-card.plat-instagram { border-top: 3px solid var(--ig); }
.stat-card.plat-instagram .stat-icon { color: var(--ig); }
.stat-card.plat-facebook  { border-top: 3px solid var(--fb); }
.stat-card.plat-facebook  .stat-icon { color: var(--fb); }
.stat-card.plat-tiktok    { border-top: 3px solid var(--tt); }
.stat-card.plat-tiktok    .stat-icon { color: var(--tt); }

/* Quick actions */
.quick-actions { margin-bottom: 32px; }
.quick-actions h2 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem; }
.action-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Tables ---- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th {
  background: var(--bg2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr.row-inactive td  { opacity: 0.5; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

.td-title   { max-width: 300px; }
.td-actions { white-space: nowrap; }
.td-actions a { margin-right: 10px; font-size: 0.82rem; color: #5b9cf6; }
.td-actions a:hover { text-decoration: underline; }
.td-actions .btn-delete  { color: #eb5757; }
.td-actions .btn-toggle  { color: #f2994a; }

/* Thumbnail mini */
.thumb-mini {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: #111;
}

.thumb-mini-ph {
  width: 64px;
  height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #222;
}

.thumb-mini-ph.plat-youtube   { color: var(--yt); }
.thumb-mini-ph.plat-instagram { color: var(--ig); }
.thumb-mini-ph.plat-facebook  { color: var(--fb); }
.thumb-mini-ph.plat-tiktok    { color: var(--tt); }
.thumb-mini-ph svg { width: 20px; height: 20px; }

/* Platform tag */
.plat-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plat-tag svg { width: 12px; height: 12px; }

.plat-tag.plat-youtube   { background: rgba(255,0,0,0.12);       color: var(--yt); }
.plat-tag.plat-instagram { background: rgba(225,48,108,0.12);    color: var(--ig); }
.plat-tag.plat-facebook  { background: rgba(24,119,242,0.12);    color: var(--fb); }
.plat-tag.plat-tiktok    { background: rgba(105,201,208,0.12);   color: var(--tt); }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.73rem;
  font-weight: 600;
}

.status-badge.active   { background: rgba(39,174,96,0.15); color: #6fcf97; }
.status-badge.inactive { background: rgba(136,136,136,0.15); color: var(--muted); }

/* ---- Tab filters ---- */
.tab-filters {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-cnt { font-size: 0.72rem; background: var(--border); border-radius: 20px; padding: 1px 7px; margin-left: 4px; }

/* ---- Formulários ---- */
.admin-form { max-width: 780px; }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

label small { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 0.8rem; }

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid #555;
  border-radius: 6px;
  color: #eeeeee;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(224,85,51,0.25);
}

select option { background: #111; color: var(--text); }

textarea { resize: vertical; line-height: 1.5; }
.code-area { font-family: 'Courier New', monospace; font-size: 0.82rem; }

.help-text {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.5;
}

/* Toggle switch */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.87rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
  margin-top: 6px;
}

.toggle-label input[type="checkbox"] { display: none; }

.toggle-slider {
  width: 42px;
  height: 24px;
  background: #333;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-slider { background: var(--accent); }
.toggle-label input:checked + .toggle-slider::after { transform: translateX(18px); }

/* Form actions */
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn-delete {
  margin-left: auto;
  color: #eb5757 !important;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-delete:hover { text-decoration: underline; }

/* Thumbnail preview */
.thumb-preview {
  margin-top: 10px;
  max-width: 280px;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Hint box */
.hint-box {
  background: rgba(24,119,242,0.1);
  border: 1px solid rgba(24,119,242,0.3);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.84rem;
  color: #90c0f0;
  margin-bottom: 16px;
  line-height: 1.6;
}

.hint-box a { color: #5b9cf6; }

/* ---- Settings ---- */
.settings-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.settings-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-section h2 svg { width: 20px; height: 20px; }

.plat-h.youtube   { color: var(--yt); }
.plat-h.instagram { color: var(--ig); }
.plat-h.facebook  { color: var(--fb); }
.plat-h.tiktok    { color: var(--tt); }

.import-section h2 { display: flex; align-items: center; gap: 8px; }
.import-section h2 svg { width: 22px; height: 22px; color: var(--yt); }
.import-section p  { color: var(--muted); font-size: 0.87rem; margin-bottom: 14px; }
.import-section strong { color: var(--text); }

/* Import per-platform grid */
.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.import-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.import-card h3 {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.import-card h3 svg { width: 16px; height: 16px; }
.import-card-note { font-size: 0.80rem; color: var(--muted); margin: 0; line-height: 1.4; }
.import-card-note a { color: #5b9cf6; }

.btn-ig { background: linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045); color:#fff; border:none; }
.btn-ig:hover { opacity: .88; }
.btn-tt { background: #111; color: #69C9D0; border: 1px solid #69C9D0; }
.btn-tt:hover { background: #1a1a1a; }

/* Embed instructions */
.embed-instructions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.embed-guide {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.embed-guide h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.embed-guide h3 svg { width: 16px; height: 16px; }
.embed-guide ol { margin-left: 16px; }
.embed-guide li { font-size: 0.82rem; color: var(--muted); margin: 4px 0; line-height: 1.5; }
.embed-guide code { background: #222; padding: 1px 5px; border-radius: 3px; font-size: 0.78rem; color: #90c0f0; }

/* See all link */
.see-all { display: block; text-align: right; margin-top: 12px; font-size: 0.83rem; color: #5b9cf6; }
.see-all:hover { text-decoration: underline; }

/* ---- Import URL box (post_form) ---- */
.import-url-box h2 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.import-url-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.import-url-row input[type="url"] {
  flex: 1;
  min-width: 0;
}
.import-msg {
  margin-top: 10px;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 5px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.import-success { border-color: #3d8f5f; background: #0e2b1d; color: #7ddba0; }
.import-error   { border-color: #8f3d3d; background: #2b0e0e; color: #e07070; }
.import-warning { border-color: #8f6a1a; background: #2b1e06; color: #dbb06a; }

/* ---- Cron command box (settings) ---- */
.cron-cmd-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  word-break: break-all;
}
.cron-cmd-box code {
  font-size: 0.83rem;
  color: #90c0f0;
  user-select: all;
}

#cron-run-output {
  margin-top: 14px;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: #9de; 
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
}

/* Recent posts */
.recent-posts { margin-top: 32px; }
.recent-posts h2 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

/* Empty admin */
.empty-admin {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-admin p { margin-bottom: 16px; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  transition: all 0.15s;
}

.page-btn:hover { border-color: #555; color: var(--text); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ============================================================
   RESPONSIVO ADMIN
   ============================================================ */

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .admin-wrap { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .admin-main { padding: 20px 16px 60px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-table { font-size: 0.78rem; }
  .admin-table th, .admin-table td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
