/* components.css — layout + component styles for PoisaX Channel Poster */

/* ---------- App shell ---------- */

#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2);
}

.sidebar__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #1a1206;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar__brand-text h1 {
  font-size: 16px;
  line-height: 1.2;
}

.sidebar__brand-text span {
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav__item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav__item.is-active {
  background: linear-gradient(90deg, rgba(255, 138, 0, 0.14), rgba(255, 138, 0, 0.02));
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar__status {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.status-dot.is-offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }
.status-dot.is-loading { background: var(--muted); box-shadow: none; }

/* ---------- Main ---------- */

.main {
  padding: var(--space-6) var(--space-7);
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 26px;
}

.page-header__subtitle {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
  max-width: 46ch;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1206;
  box-shadow: 0 8px 24px -8px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 28px -8px var(--accent-glow); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }

.btn-ghost {
  color: var(--muted);
  padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

.panel__body { padding: var(--space-5); }

.section {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.section:last-child { border-bottom: none; }

.section__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------- Compose grid ---------- */

.compose-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--space-5);
  align-items: start;
}

.char-counter {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.char-counter.is-over { color: var(--danger); }

textarea.message-input {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
  font-size: 14px;
}

/* ---------- Image uploader ---------- */

.uploader {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--muted);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.uploader:hover, .uploader.is-dragover {
  border-color: var(--accent);
  background: rgba(255, 138, 0, 0.04);
}
.uploader__icon {
  width: 36px;
  height: 36px;
  margin: 0 auto var(--space-3);
  opacity: 0.7;
}
.uploader__title { color: var(--text); font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.uploader__hint { font-size: 12px; }

.tab-row {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.tab-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.is-active {
  background: rgba(255, 138, 0, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.image-preview {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.image-preview__thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel-raised);
}
.image-preview__meta { flex: 1; min-width: 0; }
.image-preview__name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.image-preview__size { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Button builder ---------- */

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--space-3);
  align-items: end;
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}
.button-row label {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}
.button-row__remove {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.button-row__remove:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

.add-button-cta {
  width: 100%;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition);
}
.add-button-cta:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-2); }

/* ---------- Post options ---------- */

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  cursor: pointer;
}
.option-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Telegram preview ---------- */

.tg-preview-wrap { position: sticky; top: var(--space-6); }

.tg-preview {
  background: #17212B;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.tg-preview__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #1E2732;
}
.tg-preview__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #1a1206;
  flex-shrink: 0;
}
.tg-preview__title { font-size: 14px; font-weight: 600; color: #fff; }
.tg-preview__handle { font-size: 12px; color: #7d8b99; }

.tg-preview__body { padding: 14px 16px 16px; }
.tg-preview__image {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 12px;
  display: block;
  max-height: 280px;
  object-fit: cover;
  background: #0e1621;
}
.tg-preview__image-empty {
  width: 100%;
  height: 160px;
  border-radius: 10px;
  margin-bottom: 12px;
  background: #0e1621;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5b6b;
  font-size: 13px;
}
.tg-preview__text {
  color: #e7edf3;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.tg-preview__text:empty::before {
  content: "Your message will appear here…";
  color: #4b5b6b;
}
.tg-preview__buttons { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.tg-preview__button-row { display: flex; gap: 6px; }
.tg-preview__button {
  flex: 1;
  background: #2B5278;
  color: #cfe3f7;
  text-align: center;
  padding: 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.tg-preview__note {
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted-2);
  text-align: center;
}

/* ---------- Send bar ---------- */

.send-bar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ---------- Tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 12px var(--space-4);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  text-transform: capitalize;
}
.pill.is-ready, .pill.is-success { background: rgba(34, 197, 94, 0.12); color: #6ee7a5; }
.pill.is-error { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }
.pill.is-unavailable { background: rgba(148, 163, 184, 0.12); color: var(--muted); }

/* ---------- Empty states ---------- */

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--muted);
}
.empty-state h3 { color: var(--text); font-size: 15px; margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 38ch; margin: 0 auto; }

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1000;
}
.toast {
  min-width: 280px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-panel);
  animation: toast-in 180ms ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.is-success { background: #12291c; border: 1px solid rgba(34, 197, 94, 0.3); color: #d1fae5; }
.toast.is-error { background: #2a1414; border: 1px solid rgba(239, 68, 68, 0.3); color: #fee2e2; }
.toast.is-info { background: var(--panel-raised); border: 1px solid var(--border-strong); color: var(--text); }
.toast__close { margin-left: auto; color: inherit; opacity: 0.6; }
.toast__close:hover { opacity: 1; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 9, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  animation: fade-in 140ms ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(420px, 92vw);
  background: var(--panel-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-panel);
}
.modal h3 { font-size: 17px; margin-bottom: var(--space-4); }
.modal__row { margin-bottom: var(--space-3); }
.modal__row span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.modal__row strong { font-size: 14px; font-weight: 500; }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }

/* ---------- Login screen ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.login-card { width: min(380px, 100%); padding: var(--space-6); text-align: center; }
.login-card .sidebar__mark { margin: 0 auto var(--space-4); }
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: var(--space-5); }
.login-card form { display: flex; flex-direction: column; gap: var(--space-3); text-align: left; }
.login-error { color: #fca5a5; font-size: 13px; text-align: left; }

/* ---------- Settings form ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .compose-grid { grid-template-columns: 1fr; }
  .tg-preview-wrap { position: static; }
}

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: var(--space-3) var(--space-4);
  }
  .sidebar__brand-text span { display: none; }
  .nav { flex-direction: row; flex: none; }
  .sidebar__status { display: none; }
  .main { padding: var(--space-4); }
  .settings-grid { grid-template-columns: 1fr; }
  .button-row { grid-template-columns: 1fr; }
  .button-row__remove { width: 100%; }
}
