/* =====================================================================
   Chirpify - Stylesheet
   ===================================================================== */

:root {
  --color-primary: #1d9bf0;
  --color-primary-dark: #1a8cd8;
  --color-bg: #ffffff;
  --color-bg-alt: #f7f9f9;
  --color-border: #eff3f4;
  --color-text: #0f1419;
  --color-text-muted: #536471;
  --color-danger: #f4212e;
  --color-danger-bg: #fdecee;
  --color-success: #00ba7c;
  --color-success-bg: #e7f9f2;
  --sidebar-width: 260px;
  --rightbar-width: 320px;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }
ul { margin: 0; padding-left: 1.2em; }

/* ---------------- Layout ---------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 600px) var(--rightbar-width);
  justify-content: center;
  gap: 0 24px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
  align-items: start;
}

.sidebar-left {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-right: 1px solid var(--color-border);
}

.logo {
  font-size: 28px;
  padding: 12px;
  display: inline-block;
  border-radius: 50%;
  width: 24px;
  text-align: center;
}
.logo:hover { background: var(--color-bg-alt); }

.main-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 500;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--color-bg-alt); }
.nav-item.active { font-weight: 800; }
.nav-icon { font-size: 22px; width: 26px; text-align: center; }
.badge {
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: auto;
}

.btn-compose {
  margin-top: 16px;
  width: 100%;
  padding: 14px;
  font-size: 17px;
}

.account-chip {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 999px;
}
.account-chip:hover { background: var(--color-bg-alt); }
.account-chip-text { display: flex; flex-direction: column; font-size: 14px; overflow: hidden; }
.account-chip-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-chip-text span { color: var(--color-text-muted); font-size: 13px; }
.logout-link { margin-left: auto; font-size: 18px; padding: 6px; border-radius: 50%; }
.logout-link:hover { background: var(--color-border); }

.content {
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  min-height: 100vh;
  background: var(--color-bg);
}

.sidebar-right {
  padding: 12px 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* ---------------- Buttons ---------------- */
.btn-primary, .btn-secondary, .btn-danger, .btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: transparent; color: var(--color-text); border: 1px solid #cfd9de; }
.btn-secondary:hover { background: var(--color-bg-alt); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger-outline { background: transparent; color: var(--color-danger); border: 1px solid var(--color-danger); }
.btn-block { width: 100%; }
.btn-xs { padding: 6px 12px; font-size: 13px; }
.btn-icon { cursor: pointer; font-size: 20px; padding: 8px; border-radius: 50%; }
.btn-icon:hover { background: var(--color-bg-alt); }
.btn-icon-outline {
  border: 1px solid #cfd9de; border-radius: 999px; padding: 8px 12px; font-size: 16px;
}

.btn-follow {
  border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 14px; cursor: pointer; border: none;
}
.btn-follow.is-following { background: transparent; border: 1px solid #cfd9de; color: var(--color-text); }
.btn-follow.is-following .label-hover { display: none; color: var(--color-danger); }
.btn-follow.is-following:hover { border-color: var(--color-danger); color: var(--color-danger); background: var(--color-danger-bg); }
.btn-follow.is-following:hover .label-default { display: none; }
.btn-follow.is-following:hover .label-hover { display: inline; }
.btn-follow:not(.is-following) .label-hover { display: none; }

/* ---------------- Avatars ---------------- */
.avatar { border-radius: 50%; object-fit: cover; background: var(--color-bg-alt); }
.avatar-xs { width: 20px; height: 20px; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 80px; height: 80px; border: 4px solid var(--color-bg); }
.avatar-xl { width: 132px; height: 132px; border: 4px solid var(--color-bg); }

/* ---------------- Flash / hints ---------------- */
.flash { margin: 12px 16px; padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.flash-success { background: var(--color-success-bg); color: #036b48; }
.flash-error { background: var(--color-danger-bg); color: #a8121c; }
.hint, .muted { color: var(--color-text-muted); }
.hint { padding: 8px 16px; font-size: 14px; }
.small { font-size: 13px; }
.block { display: block; }

/* ---------------- Column header ---------------- */
.column-header {
  position: sticky; top: 0; background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
  padding: 14px 16px; border-bottom: 1px solid var(--color-border); z-index: 5;
}
.column-header h1 { margin: 0; font-size: 20px; }
.column-header-back { display: flex; align-items: center; gap: 20px; }
.back-link { font-size: 20px; padding: 8px; border-radius: 50%; }
.back-link:hover { background: var(--color-bg-alt); }
.chat-header-user { display: flex; align-items: center; gap: 10px; }
.chat-header-user h1 { font-size: 16px; }

/* ---------------- Hero / auth ---------------- */
.hero-card { padding: 32px 24px; text-align: center; }
.hero-card h1 { font-size: 26px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.auth-form input { padding: 12px; border-radius: 8px; border: 1px solid #cfd9de; font-size: 15px; color: var(--color-text); }
.auth-switch { margin-top: 16px; font-size: 14px; text-align: center; }
.auth-switch a { color: var(--color-primary); font-weight: 600; }

/* ---------------- Compose ---------------- */
.inline-compose, .compose-form { padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.compose-row { display: flex; gap: 12px; }
.compose-row textarea {
  flex: 1; border: none; resize: none; font-size: 18px; min-height: 60px; font-family: inherit;
  outline: none; padding-top: 10px;
}
.compose-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-left: 60px; }
.inline-reply { border-bottom: 1px solid var(--color-border); }

/* ---------------- Tweet cards ---------------- */
.tweet-list { }
.tweet {
  padding: 12px 16px; border-bottom: 1px solid var(--color-border); cursor: default;
}
.tweet-row { display: flex; gap: 12px; }
.tweet-avatar-link { flex-shrink: 0; }
.tweet-body { flex: 1; min-width: 0; }
.tweet-meta-line { color: var(--color-text-muted); font-size: 13px; font-weight: 600; margin-bottom: 4px; padding-left: 28px; }
.tweet-header { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 15px; }
.tweet-author strong { font-weight: 700; }
.tweet-handle { color: var(--color-text-muted); }
.dot { color: var(--color-text-muted); }
.tweet-time { color: var(--color-text-muted); }
.tweet-time:hover { text-decoration: underline; }
.tweet-delete { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .6; font-size: 14px; }
.tweet-delete:hover { opacity: 1; }
.tweet-reply-to { color: var(--color-text-muted); font-size: 14px; margin: 2px 0; }
.tweet-reply-to a { color: var(--color-primary); }
.tweet-content-link { display: block; }
.tweet-content { font-size: 16px; white-space: pre-wrap; word-wrap: break-word; margin: 2px 0 8px; }
.tweet-content-lg { font-size: 22px; margin: 12px 0; }
.tweet-link { color: var(--color-primary); }
.tweet-image-wrap { margin: 8px 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--color-border); }
.tweet-image { width: 100%; display: block; max-height: 500px; object-fit: cover; }
.tweet-quoted { border: 1px solid var(--color-border); border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.tweet-quoted.muted { color: var(--color-text-muted); font-style: italic; }
.tweet-quoted-header { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 4px; }
.tweet-detail .tweet-content { font-size: 22px; }

.tweet-actions { display: flex; align-items: center; justify-content: space-between; max-width: 425px; margin-top: 6px; }
.action-btn {
  background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  color: var(--color-text-muted); font-size: 14px; padding: 6px 8px; border-radius: 999px;
}
.action-btn:hover { background: var(--color-bg-alt); }
.action-btn.active.action-like { color: var(--color-danger); }
.action-btn.active.action-retweet { color: var(--color-success); }
.action-btn.active.action-bookmark { color: var(--color-primary); }
.action-btn .count { min-width: 10px; }

.thread-parent { padding: 12px 16px 0; position: relative; }
.thread-line { width: 2px; background: var(--color-border); height: 20px; margin-left: 36px; }

.empty-state { padding: 40px 24px; text-align: center; color: var(--color-text-muted); }

.pagination { display: flex; justify-content: space-between; padding: 16px; font-weight: 600; color: var(--color-primary); }

/* ---------------- Profile ---------------- */
.profile-header { border-bottom: 1px solid var(--color-border); }
.profile-banner { height: 200px; background-color: var(--color-bg-alt); background-size: cover; background-position: center; }
.profile-meta { padding: 12px 16px; position: relative; }
.profile-avatar { margin-top: -66px; background: var(--color-bg); }
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.profile-identity h2 { margin: 12px 0 0; font-size: 20px; display: flex; align-items: center; gap: 4px; }
.profile-bio { margin: 8px 0; white-space: pre-wrap; }
.profile-extra { display: flex; flex-wrap: wrap; gap: 12px; color: var(--color-text-muted); font-size: 14px; margin: 8px 0; }
.profile-extra a { color: var(--color-primary); }
.profile-stats { display: flex; gap: 16px; font-size: 14px; color: var(--color-text-muted); }
.profile-stats strong { color: var(--color-text); }
.pill {
  display: inline-block; background: var(--color-bg-alt); color: var(--color-text-muted);
  font-size: 12px; padding: 2px 8px; border-radius: 999px; margin-left: 4px;
}
.pill-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.verified, .admin-badge { font-size: 14px; }

.profile-tabs { display: flex; border-bottom: 1px solid var(--color-border); overflow-x: auto; }
.profile-tabs a { padding: 16px; font-weight: 600; color: var(--color-text-muted); white-space: nowrap; }
.profile-tabs a:hover { background: var(--color-bg-alt); }
.profile-tabs a.active { color: var(--color-text); border-bottom: 3px solid var(--color-primary); }

/* ---------------- Right sidebar ---------------- */
.search-box { margin: 4px 0 12px; }
.search-box input {
  width: 100%; padding: 12px 16px; border-radius: 999px; border: none; background: var(--color-bg-alt); font-size: 15px;
}
.panel { background: var(--color-bg-alt); border-radius: var(--radius); padding: 4px 0 8px; margin-bottom: 16px; }
.panel h2 { font-size: 19px; padding: 8px 16px; margin: 0; }
.panel-block { background: var(--color-bg-alt); padding: 16px; }
.trend-item { display: flex; justify-content: space-between; padding: 8px 16px; font-size: 14px; }
.trend-item:hover { background: rgba(0,0,0,.03); }
.trend-item-lg { align-items: center; gap: 12px; }
.trend-rank { font-size: 18px; color: var(--color-text-muted); width: 24px; }
.trend-tag { font-weight: 700; }
.trend-count { color: var(--color-text-muted); }
.suggestion-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.suggestion-item:hover { background: rgba(0,0,0,.03); }
.suggestion-text { display: flex; flex-direction: column; font-size: 14px; overflow: hidden; }
.suggestion-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-text span { color: var(--color-text-muted); }
.footer-links { padding: 8px 16px; font-size: 12px; color: var(--color-text-muted); }

/* ---------------- Lists / users ---------------- */
.user-list-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.user-list-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-list { }
.inline-form { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.inline-form input[type=text] { flex: 1; padding: 8px 12px; border-radius: 999px; border: 1px solid #cfd9de; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }

/* ---------------- Settings forms ---------------- */
.settings-form { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.settings-form input, .settings-form textarea {
  padding: 10px 12px; border-radius: 8px; border: 1px solid #cfd9de; font-size: 15px; font-family: inherit; color: var(--color-text);
}
.settings-form textarea { min-height: 80px; resize: vertical; }
.settings-form h2 { font-size: 17px; margin: 8px 0 -4px; }
.form-preview-header {
  height: 150px; border-radius: 12px; background-size: cover; background-position: center; background-color: var(--color-bg-alt);
  display: flex; align-items: flex-end; padding: 12px;
}

/* ---------------- Notifications ---------------- */
.notification-list { }
.notification-item { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--color-border); align-items: flex-start; }
.notification-item.unread { background: #f5faff; }
.notification-item:hover { background: var(--color-bg-alt); }
.notification-icon { font-size: 20px; width: 28px; text-align: center; }
.notification-text { font-size: 15px; }

/* ---------------- Messages / chat ---------------- */
.conversation-list { }
.conversation-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.conversation-item.unread { background: #f5faff; font-weight: 600; }
.conversation-item:hover { background: var(--color-bg-alt); }
.conversation-text { display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
.conversation-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }

.chat-window { padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 50vh; }
.chat-bubble-row { display: flex; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble {
  background: var(--color-bg-alt); padding: 10px 14px; border-radius: 18px; max-width: 70%; font-size: 15px; position: relative;
}
.chat-bubble-row.mine .chat-bubble { background: var(--color-primary); color: #fff; }
.chat-time { display: block; font-size: 10px; opacity: .7; margin-top: 4px; }
.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--color-border); position: sticky; bottom: 0; background: var(--color-bg); }
.chat-form input { flex: 1; padding: 12px 16px; border-radius: 999px; border: 1px solid #cfd9de; font-size: 15px; }

.inline-search-form { padding: 12px 16px; }
.inline-search-form input[type=text] { width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid #cfd9de; }

/* ---------------- Modal (compose) ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(91,112,131,.4); display: flex; align-items: flex-start;
  justify-content: center; padding-top: 60px; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal { background: var(--color-bg); border-radius: 16px; width: 100%; max-width: 600px; padding: 12px; position: relative; }
.modal-close { position: absolute; top: 8px; left: 8px; background: none; border: none; font-size: 22px; cursor: pointer; padding: 6px 10px; border-radius: 50%; }
.modal-close:hover { background: var(--color-bg-alt); }
.modal .compose-form { border: none; padding-top: 36px; }

.fab {
  display: none; position: fixed; bottom: 20px; right: 20px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--color-primary); color: #fff; border: none; font-size: 22px; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 50;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--color-text); color: #fff;
  padding: 10px 20px; border-radius: 999px; font-size: 14px; z-index: 200; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* ---------------- Admin ---------------- */
.admin-body { background: var(--color-bg-alt); }
.admin-shell { display: grid; grid-template-columns: 240px 1fr; max-width: 1280px; margin: 0 auto; min-height: 100vh; }
.admin-sidebar { background: var(--color-bg); border-right: 1px solid var(--color-border); padding: 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.admin-content { padding: 0 0 40px; background: var(--color-bg); min-height: 100vh; }
.admin-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; padding: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; padding: 16px; }
.stat-tile { background: var(--color-bg-alt); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 26px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--color-text-muted); }
.stat-warn .stat-value { color: #b8860b; }
.stat-danger .stat-value { color: var(--color-danger); }

.admin-table-wrap { overflow-x: auto; padding: 0 16px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 10px; border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: middle; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.reason-input { padding: 6px 10px; border-radius: 8px; border: 1px solid #cfd9de; width: 140px; }

.report-list { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.report-item { border-radius: 12px; }
.report-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.quoted-preview { font-style: italic; color: var(--color-text-muted); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 88px minmax(0, 600px); }
  .sidebar-right { display: none; }
  .nav-label, .account-chip-text, .btn-compose .nav-label { display: none; }
  .btn-compose { font-size: 0; padding: 14px; }
  .btn-compose::after { content: '✏️'; font-size: 20px; }
  .account-chip { justify-content: center; }
}

@media (max-width: 680px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar-left {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; width: 100%;
    flex-direction: row; justify-content: space-around; padding: 6px; border-right: none; border-top: 1px solid var(--color-border);
    background: var(--color-bg); z-index: 40;
  }
  .logo, .btn-compose, .account-chip { display: none; }
  .main-nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { padding: 10px; }
  .content { border: none; padding-bottom: 60px; }
  .fab { display: flex; align-items: center; justify-content: center; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
}
