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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22253a;
  --bg-secondary: #1a1d27;
  --border: #2e3150;
  --accent: #4f6ef7;
  --accent2: #6c3fc5;
  --danger: #e05050;
  --success: #3ecf72;
  --warn: #f5a623;
  --text: #e8eaf0;
  --muted: #7880a0;
  --radius: 10px;
}

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

/* ── LOGIN ── */
#login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d27 100%);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 48px 40px; width: 360px; text-align: center;
}
.login-box .logo { font-size: 28px; font-weight: 700; margin-bottom: 6px; }
.login-box .logo span { color: var(--accent); }
.login-box .tagline { color: var(--muted); font-size: 13px; margin-bottom: 32px; }
.login-box input {
  width: 100%; padding: 12px 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; margin-bottom: 14px;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button {
  width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-box button:hover { opacity: 0.9; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ── APP LAYOUT ── */
#app-page { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
#sidebar {
  width: 260px; min-width: 260px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
}
.sidebar-header {
  padding: 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-logo { font-size: 20px; font-weight: 700; }
.sidebar-logo span { color: var(--accent); }
.btn-logout { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; }
.btn-logout:hover { color: var(--danger); }

.sidebar-section { padding: 14px 16px 6px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

#cliente-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.cliente-item {
  padding: 10px 12px; border-radius: var(--radius); cursor: pointer; margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px; transition: background .15s;
}
.cliente-item:hover { background: var(--surface2); }
.cliente-item.active { background: var(--accent); color: #fff; }
.cliente-item .c-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent2);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.cliente-item.active .c-avatar { background: rgba(255,255,255,0.2); }
.cliente-item .c-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.btn-novo-cliente {
  width: 100%; padding: 9px; background: transparent; border: 1px dashed var(--border);
  border-radius: var(--radius); color: var(--muted); cursor: pointer; font-size: 13px;
}
.btn-novo-cliente:hover { border-color: var(--accent); color: var(--accent); }

/* Main */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; gap: 12px;
}
#topbar h1 { font-size: 18px; font-weight: 600; flex: 1; }
.btn { padding: 8px 18px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 12px 24px 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.tab-btn {
  padding: 8px 18px; border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

#content { flex: 1; overflow-y: auto; padding: 24px; }

/* Placeholder */
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

/* ── Redes ── */
.redes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.rede-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.rede-card .rede-icon { font-size: 24px; }
.rede-card .rede-name { font-size: 13px; font-weight: 600; }
.rede-card .rede-conta { font-size: 12px; color: var(--muted); }
.rede-card .rede-actions { display: flex; gap: 6px; margin-top: 4px; }
.rede-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-fb { background: #1877f215; color: #1877f2; }
.badge-ig { background: #e10c7115; color: #e10c71; }
.badge-yt { background: #ff000015; color: #ff0000; }
.badge-gmb { background: #34a85315; color: #34a853; }

.oauth-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.btn-oauth {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn-oauth:hover { border-color: var(--accent); }

/* ── Post Form ── */
.post-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; max-width: 780px;
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 100px; }

.redes-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.rede-check-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s;
}
.rede-check-item:hover { border-color: var(--accent); }
.rede-check-item input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.rede-check-item .rci-icon { font-size: 18px; }
.rede-check-item .rci-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.media-preview { margin-top: 10px; }
.media-preview img, .media-preview video { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }

.schedule-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.schedule-toggle {
  display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.schedule-toggle button {
  padding: 8px 18px; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px;
}
.schedule-toggle button.active { background: var(--accent); color: #fff; }

/* ── Posts History ── */
.posts-list { display: flex; flex-direction: column; gap: 10px; }
.post-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 16px; align-items: flex-start;
}
.post-thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.post-info { flex: 1; }
.post-info .pi-text { font-size: 14px; line-height: 1.4; margin-bottom: 8px; }
.post-info .pi-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status-badge {
  padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.status-publicado { background: #3ecf7220; color: var(--success); }
.status-agendado { background: #4f6ef720; color: var(--accent); }
.status-publicando { background: #f5a62320; color: var(--warn); }
.status-erro { background: #e0505020; color: var(--danger); }
.status-cancelado { background: #7880a020; color: var(--muted); }
.pi-date { font-size: 12px; color: var(--muted); }
.pi-redes { display: flex; gap: 4px; flex-wrap: wrap; }
.post-actions { display: flex; flex-direction: column; gap: 6px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.stat-card .sv { font-size: 28px; font-weight: 700; }
.stat-card .sl { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; width: 90%; max-width: 440px;
}
.modal h3 { margin-bottom: 18px; font-size: 17px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Toast */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  padding: 12px 20px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  animation: slideIn .2s ease; max-width: 320px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }
@keyframes slideIn { from { transform: translateX(40px); opacity:0; } to { transform: none; opacity:1; } }

/* ── Calendário ── */
.calendario-wrapper { max-width: 100%; }
.calendario-header { margin-bottom: 24px; }
.calendario-header h3 { margin-bottom: 6px; font-size: 18px; font-weight: 600; }
.calendario {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.calendario thead th { padding: 12px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface2); border-bottom: 1px solid var(--border); }
.calendario tbody td { padding: 8px; text-align: center; border: 1px solid var(--border); height: 80px; position: relative; background: var(--bg); cursor: pointer; transition: background .15s; }
.calendario tbody td:hover { background: var(--surface2); }
.calendario tbody td > div { display: flex; align-items: center; justify-content: center; height: 24px; font-size: 14px; font-weight: 600; }
.cal-vazia { cursor: default; background: transparent; border: none; }
.cal-hoje { background: var(--accent2); }
.cal-hoje > div { color: var(--accent); }
.cal-badge { position: absolute; top: 4px; right: 4px; background: var(--accent); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }

@media (max-width: 700px) {
  #sidebar { display: none; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .calendario tbody td { height: 60px; padding: 4px; }
  .calendario thead th { padding: 8px; font-size: 11px; }
}
