/* =============================================
   TK Social — app.css
   ============================================= */

:root {
  --bg: #0b1220;
  --card: #0f1a2f;
  --text: #e8eefc;
  --muted: #a8b3cf;
  --line: rgba(255,255,255,.10);
  --primary: #4f8cff;
  --primary-dark: #2f67ff;
  --danger: rgba(255,67,67,.12);
  --danger-border: rgba(255,67,67,.35);
  --ok: rgba(67,255,120,.12);
  --ok-border: rgba(67,255,120,.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #070b14, #0b1220);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { opacity: .85; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* --- Container --- */
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* --- Topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(11,18,32,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 900; letter-spacing: .2px; font-size: 18px; }
.nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- Card --- */
.card {
  background: rgba(15,26,47,.82);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
}

h1, h2, h3 { margin: 0 0 12px 0; }

/* --- Typography helpers --- */
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.title { font-size: 22px; font-weight: 900; }

/* --- Forms --- */
.form { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, textarea, select {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px;
  border-radius: 12px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; }

/* --- Buttons --- */
.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
.btn:hover { border-color: rgba(255,255,255,.22); }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-color: rgba(79,140,255,.6);
  color: #fff;
}
.btn.primary:hover { opacity: .9; }

/* --- Layout grid --- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: 1.4fr .9fr; gap: 14px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grow { flex: 1; }

/* --- Feed --- */
.feed { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

/* --- Post --- */
.post { border-radius: 18px; }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.post-head .user { display: flex; align-items: center; gap: 10px; }
.post-head .user div { display: flex; flex-direction: column; }
.post-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.post-text { margin: 0; line-height: 1.6; }
.post-body { margin-top: 10px; }
.post-img { max-width: 100%; border-radius: 12px; margin-top: 10px; }

/* Contatori like/commenti (riga sopra i bottoni) */
.post-counters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  margin-top: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.post-counter-left { display: flex; align-items: center; gap: 4px; }
.post-counter-right {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  padding: 0;
}
.post-counter-right:hover { color: var(--text); text-decoration: underline; }

/* Barra azioni stile Facebook (Mi piace | Commenta) */
.post-action-bar {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 4px;
}
.post-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.post-action-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.post-action-btn.liked { color: #e74c3c; }
.post-action-btn.liked:hover { background: rgba(231,76,60,.08); }

/* Menu ··· (tre puntini) */
.post-menu-wrap { position: relative; }
.post-menu-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px 10px;
  border-radius: 50%;
  font-family: inherit;
  letter-spacing: 1px;
  transition: background .15s;
}
.post-menu-btn:hover { background: rgba(255,255,255,.08); }
.post-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  min-width: 160px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  z-index: 20;
}
.post-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  border-radius: 8px;
  transition: background .15s;
}
.post-menu-item:hover { background: rgba(255,255,255,.06); }
.post-menu-item.danger { color: #e74c3c; }
.post-menu-item.danger:hover { background: rgba(231,76,60,.1); }

/* vecchi stili (compatibilità) */
.post-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* --- Like attivo (legacy) --- */
.like-btn.active { background: rgba(255,67,67,.15); border-color: rgba(255,67,67,.4); }

/* --- Avatar --- */
.avatar {
  width: 40px; height: 40px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  object-fit: cover;
}
.avatar.sm { width: 28px; height: 28px; }
.avatar.xl { width: 72px; height: 72px; }

/* --- Profile --- */
.profile-head { margin-bottom: 14px; }
.profile-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile-mini { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }

/* --- Pill / badge --- */
.pill {
  display: inline-flex; gap: 6px; align-items: center;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
}

/* --- Comments --- */
.comments { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.comment-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.comment {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
}
.comment .avatar { width: 32px; height: 32px; flex-shrink: 0; }
.bubble { flex: 1; font-size: 14px; line-height: 1.4; }
.comment-form {
  position: relative;
  display: flex;
  align-items: center;
}
.comment-input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 50px 10px 14px;
  border-radius: 20px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
.comment-input:focus { border-color: var(--primary); }
.comment-input::placeholder { color: var(--muted); }
.comment-send {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
  opacity: .7;
}
.comment-send:hover { opacity: 1; }

/* --- Edit form (inline) --- */
.edit-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* --- Table --- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; font-size: 14px; }
.table-wrap { overflow-x: auto; }

/* --- Alert / Flash --- */
.alert {
  background: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.flash {
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.flash-ok {
  background: var(--ok);
  border: 1px solid var(--ok-border);
  color: #d7ffe2;
}
.flash-error {
  background: var(--danger);
  border: 1px solid var(--danger-border);
}

/* --- Auth --- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  padding: 24px; gap: 12px;
}
.auth-card { width: min(520px, 100%); }
.auth-foot { text-align: center; padding: 10px 0; }

/* --- Responsive --- */
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .fb-profile-bar { flex-direction: column; text-align: center; }
  .fb-avatar-wrap { margin-top: -50px; }
  .fb-info { align-items: center; }
  .fb-actions { width: 100%; justify-content: center; }
  .fb-tabs { justify-content: center; }
}

/* =============================================
   Profilo stile Facebook
   ============================================= */

/* Cover */
.fb-cover-wrap {
  margin: -16px -16px 0 -16px;
}
.fb-cover {
  position: relative;
  width: 100%;
  height: 320px;
  background: linear-gradient(135deg, #1a2a4a, #0f1a2f);
  background-size: cover;
  background-position: center;
  border-radius: 0 0 12px 12px;
}
.fb-cover-edit {
  position: absolute;
  bottom: 16px;
  right: 16px;
}
.fb-cover-btn {
  cursor: pointer;
  font-size: 13px;
  background: rgba(0,0,0,.55) !important;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.2) !important;
}

/* Profile bar (avatar + info + actions) */
.fb-profile-bar {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  padding: 0 24px 16px;
  flex-wrap: wrap;
}

/* Avatar sovrapposto */
.fb-avatar-wrap {
  position: relative;
  margin-top: -64px;
  flex-shrink: 0;
}
.fb-avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--card);
  object-fit: cover;
  background: var(--card);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.fb-avatar-edit {
  position: absolute;
  bottom: 8px;
  right: 4px;
}
.fb-avatar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.2);
  cursor: pointer;
  font-size: 16px;
  transition: background .15s;
}
.fb-avatar-btn:hover { background: rgba(0,0,0,.8); }

/* Info */
.fb-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}
.fb-name {
  font-size: 28px;
  font-weight: 900;
  margin: 0;
  line-height: 1.2;
}
.fb-meta {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
}
.fb-bio {
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.4;
}
.fb-details {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}
.fb-details a { color: var(--primary); }
.fb-details a:hover { text-decoration: underline; }

/* Actions */
.fb-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  padding-bottom: 4px;
}

/* Tabs */
.fb-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0 -16px 16px;
  padding: 0 24px;
  overflow-x: auto;
}
.fb-tab {
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.fb-tab:hover { color: var(--text); }
.fb-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.fb-tab.disabled {
  opacity: .4;
  cursor: default;
}

/* Compose box (stile FB) */
.fb-compose { margin-bottom: 12px; }
.fb-compose-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.compose-textarea {
  flex: 1;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  min-height: 44px;
  transition: border-color .15s;
}
.compose-textarea:focus { border-color: var(--primary); }
.compose-textarea::placeholder { color: var(--muted); }

.compose-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.compose-attach {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s;
}
.compose-attach:hover { background: rgba(255,255,255,.06); color: var(--text); }

/* Detail rows (sidebar) */
.fb-detail-row {
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.fb-detail-row:last-child { border-bottom: none; }
.fb-detail-row a { color: var(--primary); }

/* Preview copertina nelle impostazioni */
.fb-preview-cover {
  width: 100%;
  height: 100px;
  background: linear-gradient(135deg, #1a2a4a, #0f1a2f);
  background-size: cover;
  background-position: center;
  border-radius: 12px;
}

/* Preview immagine (compose) */
.fb-img-preview {
  position: relative;
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
}
.fb-img-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 12px;
}
.fb-img-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
