/* ===== RESET & BASE ===== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, #eef6f3 0%, #f0f2f5 120px, #f0f2f5 100%);
  color: #1a1a1a;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== TOPBAR ===== */

.topbar {
  background: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Градиентная полоска сверху как в оригинале */
.topbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #a8e6cf 0%, #88d8b0 25%, #7ec8a0 50%, #b8e6d0 75%, #a8e6cf 100%);
}

.topbar-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #1a1a1a;
}

.topbar-links {
  display: flex;
  gap: 24px;
}

.topbar-links a {
  color: #8e8e93;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 14px 0;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.topbar-links a.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

.topbar-links a:hover {
  color: #1a1a1a;
}

/* ===== MAIN LAYOUT ===== */

.main-layout {
  display: flex;
  gap: 24px;
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 24px;
  align-items: flex-start;
}

.editor-side {
  flex: 1;
  min-width: 0;
  max-width: 520px;
}

.preview-side {
  width: 420px;
  flex-shrink: 0;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d1d1d6 transparent;
}

.preview-side::-webkit-scrollbar {
  width: 4px;
}

.preview-side::-webkit-scrollbar-thumb {
  background: #d1d1d6;
  border-radius: 4px;
}

/* ===== EDITOR CARD ===== */

.editor-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 0;
}

.editor-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a8e6cf, #88d8b0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.editor-author {
  font-size: 15px;
  font-weight: 600;
}

.editor-body {
  padding: 12px 20px;
}

.editor-textarea {
  width: 100%;
  min-height: 200px;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
  color: #1a1a1a;
  background: transparent;
}

.editor-textarea::placeholder {
  color: #c7c7cc;
}

/* Медиа в редакторе */
.editor-media {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
}

.editor-media-item {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f2f5;
}

.editor-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.editor-media-video {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8e8e93;
  font-size: 28px;
}

.media-filename {
  font-size: 11px;
  color: #8e8e93;
  margin-top: 4px;
}

.media-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}

.editor-media-item:hover .media-remove {
  opacity: 1;
}

/* Зона загрузки */
.editor-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  cursor: pointer;
  color: #8e8e93;
  font-size: 14px;
  transition: background 0.15s;
  border-top: 1px solid #f5f5f7;
}

.editor-upload:hover,
.editor-upload.dragover {
  background: #fafafa;
  color: #1a1a1a;
}

.editor-upload input {
  display: none;
}

.upload-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 300;
  color: #8e8e93;
}

/* Планирование */
.editor-schedule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid #f5f5f7;
}

.editor-schedule input[type="datetime-local"] {
  flex: 1;
  height: 36px;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.editor-schedule input:focus {
  border-color: #1a1a1a;
}

.schedule-cancel {
  width: 28px;
  height: 28px;
  border: none;
  background: #f0f2f5;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: #8e8e93;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Подвал редактора */
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid #f5f5f7;
}

.editor-actions {
  display: flex;
  gap: 4px;
}

.footer-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  color: #8e8e93;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.footer-icon-btn:hover {
  background: #f0f2f5;
  color: #1a1a1a;
}

.editor-char-count {
  font-size: 13px;
  color: #c7c7cc;
  font-variant-numeric: tabular-nums;
}

/* Кнопка публикации */
.publish-btn {
  width: 100%;
  height: 46px;
  margin-top: 14px;
  border: none;
  border-radius: 12px;
  background: #1a1a1a;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.publish-btn:hover {
  background: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.publish-btn:active {
  transform: scale(0.98);
}

.publish-btn:disabled {
  background: #d1d1d6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ===== PLATFORM PREVIEW BLOCKS ===== */

.platform-block {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  margin-bottom: 14px;
  overflow: hidden;
}

.platform-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f7;
}

.platform-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.platform-info {
  flex: 1;
  min-width: 0;
}

.platform-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.platform-handle {
  font-size: 12px;
  color: #8e8e93;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d1d6;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: #34c759;
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* Platform preview area */
.platform-preview {
  padding: 4px 0;
  max-height: 500px;
  overflow-y: auto;
}

.preview-placeholder {
  color: #c7c7cc;
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

/* ===== SOCIAL POST (preview messages) ===== */

.social-post {
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f7;
}

.social-post:last-child {
  border-bottom: none;
}

.social-post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.social-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a8e6cf, #88d8b0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.social-name {
  font-size: 13px;
  font-weight: 600;
}

.social-handle {
  font-size: 12px;
  color: #8e8e93;
}

.social-meta {
  font-size: 12px;
  color: #8e8e93;
}

.social-post-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  color: #1a1a1a;
}

.social-post-actions {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  padding-top: 6px;
}

.social-action {
  font-size: 12px;
  color: #8e8e93;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Media inside social post */
.social-media-block {
  display: flex;
  gap: 4px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.social-media-img {
  width: 100%;
  max-height: 200px;
  border-radius: 10px;
  object-fit: cover;
}

.social-media-block:has(.social-media-img + .social-media-img) .social-media-img {
  width: calc(50% - 2px);
  max-height: 120px;
}

.social-media-video {
  width: 100%;
  height: 120px;
  background: #f0f2f5;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #8e8e93;
}

.social-media-more {
  width: calc(50% - 2px);
  height: 120px;
  background: rgba(0,0,0,0.5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

/* Mobile toggle */
.preview-mobile-toggle {
  display: none;
  width: 100%;
  padding: 12px;
  background: #fff;
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  text-align: center;
  margin-bottom: 14px;
}

/* ===== SHARED: BUTTONS ===== */

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.btn:active { opacity: 0.7; }
.btn-primary { background: #1a1a1a; color: #fff; }
.btn-primary:disabled { background: #d1d1d6; cursor: not-allowed; }
.btn-danger { background: #ff3b30; color: #fff; }
.btn-secondary { background: #f0f2f5; color: #1a1a1a; }
.btn-small { display: inline-block; width: auto; padding: 8px 16px; font-size: 14px; border-radius: 8px; }

/* ===== SHARED: CONTAINER for settings/history ===== */

.container {
  max-width: 600px;
  margin: 28px auto;
  padding: 0 16px;
}

/* ===== SHARED: CARD ===== */

.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  padding: 16px 20px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ===== SETTINGS ===== */

.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  font-size: 12px;
  color: #8e8e93;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  height: 40px;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: #1a1a1a;
  box-shadow: 0 0 0 3px rgba(26,26,26,0.06);
}

/* Channels */
.channel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f7;
  gap: 8px;
}

.channel-row:last-child { border-bottom: none; }

.channel-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.channel-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mini-toggle {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}

.mini-toggle input { width: auto; height: auto; }

/* Log */
.log-row {
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f7;
  line-height: 1.4;
}

.log-row:last-child { border-bottom: none; }

/* ===== HISTORY ===== */

.post-item {
  padding: 12px 0;
  border-bottom: 1px solid #f5f5f7;
}

.post-item:last-child { border-bottom: none; }

.post-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.post-status.published { background: #d4edda; color: #155724; }
.post-status.scheduled { background: #fff3cd; color: #856404; }
.post-status.failed { background: #f8d7da; color: #721c24; }
.post-status.draft { background: #f0f2f5; color: #8e8e93; }

.post-meta {
  font-size: 13px;
  color: #8e8e93;
  margin-top: 4px;
}

.post-text {
  font-size: 14px;
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.post-platforms {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.post-platform {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.post-platform.ok { background: #d4edda; color: #155724; }
.post-platform.fail { background: #f8d7da; color: #721c24; }
.post-platform.pending { background: #f0f2f5; color: #8e8e93; }

/* ===== AUTH ===== */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  background: linear-gradient(180deg, #eef6f3 0%, #f0f2f5 30%);
}

.auth-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  padding: 48px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-card h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 32px;
  text-transform: uppercase;
}

.auth-card input {
  margin-bottom: 16px;
}

/* ===== TOAST ===== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  animation: slideUp 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.success { background: #1a1a1a; }
.toast.error { background: #ff3b30; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== NAVBAR fallback for settings/history ===== */

.navbar {
  background: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #a8e6cf 0%, #88d8b0 25%, #7ec8a0 50%, #b8e6d0 75%, #a8e6cf 100%);
}

.navbar h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.navbar-links {
  display: flex;
  gap: 24px;
}

.navbar-links a {
  color: #8e8e93;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 14px 0;
  border-bottom: 2px solid transparent;
}

.navbar-links a.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

.navbar-links a:hover {
  color: #1a1a1a;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 860px) {
  .main-layout {
    flex-direction: column;
    padding: 0 12px;
    margin: 12px auto;
  }

  .editor-side {
    max-width: 100%;
  }

  .preview-side {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .preview-mobile-toggle {
    display: block;
  }

  .preview-list {
    display: none;
  }

  .preview-list.show {
    display: block;
  }
}

/* Datetime fallback */
.datetime-row {
  margin-top: 12px;
  display: none;
}

.datetime-row.visible {
  display: block;
}

/* Platform checks (for settings page, if used) */
.platform-checks {
  display: flex;
  gap: 8px;
}

.platform-check {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  user-select: none;
}

.platform-check.active {
  border-color: #1a1a1a;
  background: #fafafa;
}

.platform-check input { display: none; }

.toggle-row { display: flex; gap: 8px; }

.toggle-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.toggle-btn.active {
  border-color: #1a1a1a;
  background: #1a1a1a;
  color: #fff;
}
