/* Raitoy Social Automation - admin panel theme */

:root {
  --r-bg: #f4f6fb;
  --r-surface: #ffffff;
  --r-sidebar: #131a2b;
  --r-sidebar-soft: #1c2438;
  --r-border: #e4e8f0;
  --r-text: #1c2434;
  --r-muted: #6b7690;
  --r-brand: #5b5bd6;
  --r-brand-dark: #4747b8;
  --r-brand-soft: #eef0ff;
  --r-success: #17a673;
  --r-warning: #e8a33d;
  --r-danger: #e05260;
  --r-radius: 14px;
  --r-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px -12px rgba(16, 24, 40, 0.18);
}

body {
  background: var(--r-bg);
  color: var(--r-text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.94rem;
  min-height: 100vh;
}

a {
  color: var(--r-brand);
  text-decoration: none;
}
a:hover {
  color: var(--r-brand-dark);
  text-decoration: underline;
}

/* ---------------------------------------------------------------- layout */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--r-sidebar);
  color: #aeb7cc;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff;
}

.sidebar-brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6d6df0, #9a6ef0);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  color: #fff;
  flex: 0 0 auto;
}

.sidebar-brand .name {
  font-weight: 650;
  line-height: 1.15;
  font-size: 0.97rem;
}
.sidebar-brand .sub {
  font-size: 0.7rem;
  color: #8f9ab5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 0.85rem 0.7rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.sidebar-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #6c7794;
  padding: 0.9rem 0.65rem 0.4rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #b9c1d6;
  border-radius: 10px;
  padding: 0.56rem 0.7rem;
  margin-bottom: 0.15rem;
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
}
.sidebar-nav .nav-link i {
  font-size: 1.02rem;
  width: 1.2rem;
  text-align: center;
}
.sidebar-nav .nav-link:hover {
  background: var(--r-sidebar-soft);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: linear-gradient(135deg, rgba(109, 109, 240, 0.95), rgba(140, 110, 240, 0.85));
  color: #fff;
  box-shadow: 0 6px 18px -8px rgba(109, 109, 240, 0.9);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 0.85rem 0.9rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #d5daea;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}
.sidebar-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--r-sidebar-soft);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
}

.btn-logout {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: #b9c1d6;
  border-radius: 9px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}
.btn-logout:hover {
  background: rgba(224, 82, 96, 0.14);
  border-color: rgba(224, 82, 96, 0.5);
  color: #ffb3bb;
}

.main-area {
  flex: 1 1 auto;
  margin-left: 264px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--r-surface);
  border-bottom: 1px solid var(--r-border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar h1 {
  font-size: 1.12rem;
  font-weight: 650;
  margin: 0;
}
.topbar .page-sub {
  font-size: 0.8rem;
  color: var(--r-muted);
  margin: 0;
}

.content {
  padding: 1.5rem;
  flex: 1 1 auto;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .main-area {
    margin-left: 0;
  }
  .content {
    padding: 1rem;
  }
}

/* ----------------------------------------------------------------- cards */

.card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
  box-shadow: var(--r-shadow);
  background: var(--r-surface);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--r-border);
  padding: 0.95rem 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-body {
  padding: 1.15rem;
}

.stat-card {
  padding: 1.05rem 1.15rem;
  height: 100%;
}
.stat-card .stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  margin-bottom: 0.7rem;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 680;
  line-height: 1.1;
}
.stat-card .stat-label {
  color: var(--r-muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.stat-card .stat-hint {
  font-size: 0.76rem;
  color: var(--r-muted);
  margin-top: 0.35rem;
}

.tint-brand { background: var(--r-brand-soft); color: var(--r-brand); }
.tint-success { background: #e4f7ef; color: var(--r-success); }
.tint-warning { background: #fdf2e1; color: #b9781f; }
.tint-danger { background: #fdeaec; color: var(--r-danger); }
.tint-info { background: #e6f2fe; color: #2a7fd4; }
.tint-slate { background: #eef1f6; color: #546079; }

/* ---------------------------------------------------------------- tables */

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  font-size: 0.89rem;
}
.table > thead th {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--r-muted);
  font-weight: 650;
  border-bottom: 1px solid var(--r-border);
  padding: 0.7rem 0.9rem;
  white-space: nowrap;
}
.table > tbody td {
  padding: 0.8rem 0.9rem;
  vertical-align: middle;
  border-bottom: 1px solid #f0f2f7;
}
.table > tbody tr:last-child td {
  border-bottom: 0;
}
.table-hover > tbody > tr:hover > * {
  background: #fafbfe;
}

.cell-title {
  font-weight: 600;
  color: var(--r-text);
}
.cell-sub {
  font-size: 0.78rem;
  color: var(--r-muted);
}

/* ---------------------------------------------------------------- badges */

.badge {
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.65em;
  border-radius: 7px;
}
.badge-soft-success { background: #e4f7ef; color: #0f7d57; }
.badge-soft-danger { background: #fdeaec; color: #b8323f; }
.badge-soft-warning { background: #fdf2e1; color: #a06a16; }
.badge-soft-info { background: #e6f2fe; color: #1f6cb5; }
.badge-soft-brand { background: var(--r-brand-soft); color: var(--r-brand-dark); }
.badge-soft-slate { background: #eef1f6; color: #566078; }

.kw-chip {
  display: inline-block;
  background: var(--r-brand-soft);
  color: var(--r-brand-dark);
  border-radius: 7px;
  padding: 0.16rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 600;
  margin: 0.1rem 0.15rem 0.1rem 0;
}

/* ----------------------------------------------------------------- forms */

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.form-text {
  font-size: 0.78rem;
}
.form-control,
.form-select {
  border-color: #dde2ec;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
.form-control:focus,
.form-select:focus {
  border-color: #b4b4ee;
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.13);
}
textarea.form-control {
  line-height: 1.55;
}

.btn {
  border-radius: 10px;
  font-weight: 550;
  font-size: 0.88rem;
  padding: 0.46rem 0.95rem;
}
.btn-primary {
  background: var(--r-brand);
  border-color: var(--r-brand);
}
.btn-primary:hover,
.btn-primary:focus {
  background: var(--r-brand-dark);
  border-color: var(--r-brand-dark);
}
.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.form-switch .form-check-input {
  width: 2.35em;
  height: 1.25em;
}
.form-check-input:checked {
  background-color: var(--r-brand);
  border-color: var(--r-brand);
}

.option-card {
  border: 1px solid var(--r-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  height: 100%;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.option-card:hover {
  border-color: #c3c3ee;
}
.option-card input:checked ~ .option-body .option-title {
  color: var(--r-brand-dark);
}
.option-card.selected {
  border-color: var(--r-brand);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.12);
  background: #fcfcff;
}
.option-title {
  font-weight: 620;
  font-size: 0.9rem;
}
.option-desc {
  font-size: 0.78rem;
  color: var(--r-muted);
}

.keyword-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--r-muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.var-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  background: #f1f3f9;
  border: 1px solid #e2e6ef;
  border-radius: 7px;
  padding: 0.16rem 0.42rem;
  color: #46506a;
  cursor: pointer;
}
.var-chip:hover {
  background: var(--r-brand-soft);
  border-color: #c7c7f0;
  color: var(--r-brand-dark);
}

/* ------------------------------------------------------------- empty ui */

.empty-state {
  text-align: center;
  padding: 2.75rem 1rem;
  color: var(--r-muted);
}
.empty-state .empty-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--r-brand-soft);
  color: var(--r-brand);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  margin: 0 auto 0.9rem;
}
.empty-state h6 {
  color: var(--r-text);
  font-weight: 650;
  margin-bottom: 0.35rem;
}

/* --------------------------------------------------------------- media */

.media-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: linear-gradient(135deg, #2b3350, #4a3f7a);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  overflow: hidden;
}
.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --------------------------------------------------------------- misc */

.message-preview {
  white-space: pre-wrap;
  background: #f8f9fd;
  border: 1px dashed #d8dde9;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 0.87rem;
  line-height: 1.6;
  min-height: 3rem;
}

.chat-bubble {
  white-space: pre-wrap;
  background: linear-gradient(135deg, #f0f1ff, #f7f2ff);
  border: 1px solid #e0e1fb;
  border-radius: 14px 14px 14px 4px;
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  line-height: 1.6;
}

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  max-width: min(380px, calc(100vw - 2rem));
}

.demo-ribbon {
  background: #fdf2e1;
  color: #8a5a10;
  border: 1px solid #f3dcb2;
  border-radius: 9px;
  padding: 0.18rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 650;
}

.code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  background: #f1f3f9;
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  color: #46506a;
  word-break: break-all;
}

.timeline-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #f0f2f7;
}
.timeline-item:last-child {
  border-bottom: 0;
}
.timeline-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--r-brand-soft);
  color: var(--r-brand-dark);
  display: grid;
  place-items: center;
  font-weight: 650;
  flex: 0 0 auto;
  font-size: 0.85rem;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(1200px 500px at 15% -10%, #e9eaff 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #f2e9ff 0%, transparent 55%), var(--r-bg);
}
.login-card {
  width: min(420px, 100%);
}

.table-responsive {
  border-radius: var(--r-radius);
}

.text-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.filter-bar {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--r-shadow);
}

.htmx-request .htmx-indicator {
  display: inline-block;
}
.htmx-indicator {
  display: none;
}
