:root {
  --bg: #0f0f12;
  --card: #1a1a22;
  --border: #2a2a35;
  --text: #f0f0f5;
  --muted: #8888a0;
  --primary: #e1306c;
  --primary-hover: #c13584;
  --accent: #405de6;
  --success: #2ecc71;
  --error: #e74c3c;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 1.25rem;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions { display: flex; align-items: center; gap: 1rem; }
.user-badge { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.login-card {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
}

.login-card h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; }

h2 { font-size: 1.1rem; margin-bottom: 1rem; }
h3 { font-size: 0.95rem; margin-bottom: 0.75rem; color: var(--muted); }

label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="file"],
input[type="datetime-local"],
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

textarea { resize: vertical; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--primary); color: white; }
.btn-accent { background: var(--accent); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-danger { background: var(--error); color: white; }

.btn-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.ai-section {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-preview {
  margin-top: 0.75rem;
  max-width: 300px;
  border-radius: 8px;
  overflow: hidden;
}

.image-preview img { width: 100%; display: block; }

.ig-status {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.ig-connected { border-left: 3px solid var(--success); }
.ig-disconnected { border-left: 3px solid var(--error); }

.posts-list { display: flex; flex-direction: column; gap: 0.75rem; }

.post-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  align-items: flex-start;
}

.post-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.post-info { flex: 1; min-width: 0; }
.post-caption {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.post-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-scheduled { background: #2c3e50; color: #3498db; }
.status-published { background: #1a3a2a; color: var(--success); }
.status-failed { background: #3a1a1a; color: var(--error); }
.status-draft { background: #2a2a35; color: var(--muted); }
.status-cancelled { background: #2a2a35; color: var(--muted); }
.status-publishing { background: #2a2a45; color: #9b59b6; }

.post-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.error { color: var(--error); font-size: 0.85rem; margin-top: 0.75rem; }
.message { font-size: 0.9rem; margin-top: 0.75rem; padding: 0.5rem 0.75rem; border-radius: 6px; }
.message.success { background: #1a3a2a; color: var(--success); }
.message.error { background: #3a1a1a; color: var(--error); }

.loading { color: var(--muted); font-size: 0.85rem; margin-left: 0.5rem; }
.hidden { display: none !important; }

#login-form .btn { width: 100%; margin-top: 1.25rem; }

@media (max-width: 600px) {
  .post-item { flex-direction: column; }
  .post-actions { width: 100%; }
}
