/* ================================================================
   app.css — SocialPost Manager
   Светлая тема, фирменные цвета ya-marketing.ru
   ================================================================ */

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

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface2:  #e7eaf3;
  --border:    #dde1ee;
  --accent:    #333f64;
  --accent-h:  #28324f;
  --accent-lt: #e7eaf3;
  --red:       #fc3f1d;
  --text:      #1a2035;
  --text2:     #5a6380;
  --muted:     #9aa0b8;
  --sidebar-w: 248px;
  --radius:    10px;
  --btn-radius: 5px;
  --shadow:    0 2px 12px rgba(51,63,100,0.10);
  --shadow-lg: 0 8px 32px rgba(51,63,100,0.13);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Loader ─────────────────────────────────────────────────────── */

#app-loader {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 9999;
}

.loader-inner { text-align: center; }

.loader-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  border-radius: 16px;
  overflow: hidden;
  animation: pulse 1.5s ease-in-out infinite;
}

.loader-logo img { width: 100%; height: 100%; object-fit: cover; }

.loader-bar {
  width: 160px;
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin: 0 auto;
}

.loader-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--red));
  border-radius: 99px;
  animation: loading 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.7; transform: scale(0.95); }
}

@keyframes loading {
  0%   { width: 0%; margin-left: 0%; }
  50%  { width: 80%; margin-left: 10%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ── Auth ───────────────────────────────────────────────────────── */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-wrap {
  width: 400px;
  padding: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--accent);
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--text);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

/* ── Forms ──────────────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  resize: vertical;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51,63,100,0.1);
  background: #fff;
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.form-error {
  padding: 10px 14px;
  background: rgba(252,63,29,0.07);
  border: 1px solid rgba(252,63,29,0.2);
  border-radius: 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
}

/* ── Buttons ────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 20px 50px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 200;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  border: 0;
  transition: all .18s;
  white-space: nowrap;
}

/* Красная кнопка: градиент rgb(166,26,1) → rgb(253,101,74) */
.btn-primary {
  background: linear-gradient(0deg, rgb(166,26,1), rgb(253,101,74));
  color: #fff;
}
.btn-primary:hover {
  background: linear-gradient(0deg, rgb(253,101,74), rgb(166,26,1));
  color: #fff;
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* Светлая кнопка: градиент rgb(207,214,231) → rgb(243,244,249), инверт при наведении */
.btn-ghost {
  background: linear-gradient(0deg, rgb(207,214,231), rgb(243,244,249));
  color: var(--accent);
}
.btn-ghost:hover {
  background: linear-gradient(0deg, rgb(51,63,100), rgb(75,94,148));
  color: #fff;
}

/* Синяя кнопка: градиент rgb(51,63,100) → rgb(75,94,148), инверт при наведении */
.btn-blue {
  background: linear-gradient(0deg, rgb(51,63,100), rgb(75,94,148));
  color: #fff;
}
.btn-blue:hover {
  background: linear-gradient(0deg, rgb(75,94,148), rgb(51,63,100));
  color: #fff;
}

.btn-full { width: 100%; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface2); color: var(--accent); }
.btn-icon svg { width: 16px; height: 16px; }

.btn-loader { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Shell layout ───────────────────────────────────────────────── */

#app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--accent);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-brand .brand-name {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

/* Project switcher */
.project-switcher {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
}

.project-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  transition: background .15s;
}

.project-switcher:hover .project-current { background: rgba(255,255,255,0.1); }

.project-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.4);
}

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

.project-label {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}

.project-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron { width: 14px; height: 14px; color: rgba(255,255,255,0.4); flex-shrink: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; }

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--red);
  border-radius: 0 3px 3px 0;
}

.nav-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 6px 2px; }

.nav-section-label {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 10px 2px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-card { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.45); font-weight: 500; }
.sidebar-footer .btn-icon { color: rgba(255,255,255,0.45); }
.sidebar-footer .btn-icon:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Main content ───────────────────────────────────────────────── */

#main-content { flex: 1; overflow-y: auto; background: var(--bg); }
#page-container { padding: 32px; max-width: 1200px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--text2); margin-top: 4px; font-weight: 500; }

/* ── Dashboard cards ────────────────────────────────────────────── */

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.dash-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow);
}

.dash-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.dash-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  background: var(--accent-lt);
  color: var(--accent);
}

.dash-card-value { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.dash-card-label { font-size: 12px; color: var(--text2); font-weight: 600; }

/* ── Projects ───────────────────────────────────────────────────── */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.project-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all .2s;
  position: relative;
  box-shadow: var(--shadow);
}

.project-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.project-card--active { border-color: var(--accent); background: var(--accent-lt); }
.project-card-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.project-card-body { flex: 1; min-width: 0; }
.project-card-name { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card-desc { font-size: 12px; color: var(--text2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.project-card-check { color: var(--accent); font-size: 16px; font-weight: 800; }

/* ── Modal ──────────────────────────────────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(26,32,53,0.45);
  backdrop-filter: blur(3px);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  z-index: 1;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 800; color: var(--text); }
.modal-box form { padding: 22px 26px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.color-dot {
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .15s;
}
.color-dot.selected, .color-dot:hover { border-color: var(--accent); transform: scale(1.15); }

/* ── States ─────────────────────────────────────────────────────── */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 20px; gap: 12px;
}

.empty-icon { font-size: 44px; }
.empty-state h3 { font-size: 18px; font-weight: 800; color: var(--text); }
.empty-state p { font-size: 13px; color: var(--text2); max-width: 300px; font-weight: 500; }
.loading-state, .error-state { padding: 40px; text-align: center; color: var(--text2); font-size: 13px; font-weight: 500; }

.page-stub { padding: 80px 0; text-align: center; }

.stub-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-lt);
  border-radius: 99px;
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 20px;
  font-weight: 700;
}

.stub-title { font-size: 30px; font-weight: 800; margin-bottom: 12px; color: var(--text); }
.stub-desc { color: var(--text2); font-size: 14px; font-weight: 500; }

/* ── Toasts ─────────────────────────────────────────────────────── */

#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; }

.toast {
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}

.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(34,197,94,0.35); color: #16a34a; }
.toast-error   { border-color: rgba(252,63,29,0.3);  color: var(--red); }
.toast-info    { border-color: rgba(51,63,100,0.25); color: var(--accent); }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
/* ── Переключение форм авторизации ── */
.auth-switch {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e7eaf3;
  font-size: 13px;
  color: #64748b;
}
.auth-switch a {
  color: rgb(51, 63, 100);
  font-weight: 600;
  text-decoration: none;
}
.auth-switch a:hover {
  color: rgb(252, 63, 29);
}


/* ── Центрирование auth экрана ── */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-title { text-align: center; }
.auth-switch { text-align: center !important; }

/* ── Центрирование бренда в auth ── */
#auth-screen .auth-brand { justify-content: center; }

#auth-screen .auth-brand { justify-content: center !important; }

#auth-screen .btn-full { margin-top: 15px; }

#verify-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* ── Profile ─────────────────────────────────────────────────────── */
.profile-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 600px;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}

.profile-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 24px;
}

.profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-actions {
  display: flex;
  gap: 8px;
}

.profile-avatar-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-sm {
  padding: 8px 16px !important;
  font-size: 10px !important;
}

.form-success {
  color: #4ade80;
  font-size: 13px;
  padding: 8px 12px;
  background: rgba(74,222,128,0.08);
  border-radius: 6px;
  border: 1px solid rgba(74,222,128,0.2);
}

/* ── Social links ────────────────────────────────────────────────── */
.social-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.social-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.social-link-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.social-link-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.social-yandex-icon { background: #fc3f1d; }
.social-vk-icon     { background: #0077ff; }
.social-google-icon { background: #4285f4; }

.social-link-name   { font-size: 13px; font-weight: 600; color: var(--text); }
.social-link-status { font-size: 11px; color: #94a3b8; margin-top: 2px; }
