@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-dark: #0f0f13;
  --bg-card: #18181c;
  --bg-input: #232329;
  --text-main: #f0f0f0;
  --text-muted: #8b8b99;
  --accent-cyan: #00f0ff;
  --accent-purple: #b624ff;
  --accent-green: #5eaf2e;
  --accent-red: #ff3366;
  --border-color: #2a2a35;
  --sidebar-w: 260px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 1rem;
}

.text-cyan {
  color: var(--accent-cyan);
}

.text-purple {
  color: var(--accent-purple);
}

/* Layouts */
.layout-container {
  display: flex;
  width: 100%;
}

.main-content {
  flex: 1;
  padding: 2rem 3rem;
  margin-left: var(--sidebar-w);
  max-width: calc(100% - var(--sidebar-w));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background-color: #121215;
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.brand-text h2 {
  margin: 0;
  font-size: 1.2rem;
  background: linear-gradient(to right, #e0e0e0, #a0a0a0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(182, 36, 255, 0.3) 0%, transparent 100%);
  color: var(--text-main);
  border: 1px solid rgba(182, 36, 255, 0.6);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-emergency {
  background: rgba(255, 51, 102, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(255, 51, 102, 0.3);
  padding: 0.8rem;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-emergency:hover {
  background: rgba(255, 51, 102, 0.2);
}

/* Cards & Panels */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-purple);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;  
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 15px rgba(182, 36, 255, 0.4);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Login Page specific */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: radial-gradient(circle at center, #1a1a24 0%, var(--bg-dark) 100%);
}

.login-card {
  background: rgba(24, 24, 28, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  background: linear-gradient(to right, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.8rem;
}

/* Dashboard specific */
.stat-card {
  font-size: 3.5rem;
  font-weight: 300;
  background: linear-gradient(135deg, #fff, #a0a0a0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.activity-list {
  list-style: none;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.8rem 0;
}

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

.status-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-icon.done {
  background-color: var(--accent-green);
  color: white;
  border: none;
  font-weight: bold;
}

.status-icon.progress {
  border: 2.5px solid transparent;
  border-top-color: var(--accent-cyan);
  border-right-color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  animation: spin 1.5s linear infinite;
  box-shadow: none;
  color: transparent;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.status-icon.wait {
  color: var(--text-muted);
  border: 2px solid var(--text-muted);
}

.hitl-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 3rem;
}

.hitl-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.image-preview {
  width: 99%;
  aspect-ratio: 1/1;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* History specific */
.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  text-align: left;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
}

.history-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.badge {
  padding: 0.3rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-success {
  background: rgba(0, 255, 136, 0.1);
  color: var(--accent-green);
  border-color: rgba(0, 255, 136, 0.3);
}

.badge-failed {
  background: rgba(255, 51, 102, 0.1);
  color: var(--accent-red);
  border-color: rgba(255, 51, 102, 0.3);
}

/* Settings specific */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--bg-input);
  margin: 0 auto 1.5rem auto;
  border: 2px solid var(--accent-purple);
  overflow: hidden;
}

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

.api-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.api-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.status-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.connected {
  color: var(--accent-green);
}

.status-indicator.connected::before {
  background: var(--accent-green);
  box-shadow: 0 0 5px var(--accent-green);
}

.status-indicator.offline {
  color: var(--text-muted);
}

.status-indicator.offline::before {
  background: var(--text-muted);
}

.input-with-icon {
  position: relative;
}

.input-with-icon .form-control {
  padding-right: 2.5rem;
}

.input-with-icon .icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
}

/* ── Account Connection Cards ─────────────────────────────────────────────── */

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.account-card {
  background: rgba(24, 24, 28, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.account-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.account-card.connected {
  border-color: rgba(0, 255, 136, 0.15);
}

.account-card.loading {
  pointer-events: none;
  opacity: 0.7;
}

.account-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem 1.5rem 1rem;
}

.account-platform {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.account-platform h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.platform-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.platform-icon-x {
  background: linear-gradient(135deg, #1a1a2e, #2a2a3e);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.platform-icon-ig {
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
}

.account-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.account-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.account-status.connected {
  border-color: rgba(0, 255, 136, 0.3);
  color: var(--accent-green);
}

.account-status.connected .status-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-green 2s ease-in-out infinite;
}

.account-status.disconnected {
  border-color: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.account-status.pending {
  border-color: rgba(0, 240, 255, 0.3);
  color: var(--accent-cyan);
}

.account-status.pending .status-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-cyan 1s ease-in-out infinite;
}

@keyframes pulse-green {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 4px var(--accent-green);
  }

  50% {
    opacity: 0.6;
    box-shadow: 0 0 12px var(--accent-green);
  }
}

@keyframes pulse-cyan {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 4px var(--accent-cyan);
  }

  50% {
    opacity: 0.4;
    box-shadow: 0 0 16px var(--accent-cyan);
  }
}

.account-card-body {
  padding: 0 1.5rem;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.account-info {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  width: 100%;
  padding: 1.2rem;
  background: rgba(0, 255, 136, 0.03);
  border: 1px solid rgba(0, 255, 136, 0.08);
  border-radius: 12px;
}

.account-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e, #2a2a3e);
  border: 2px solid rgba(0, 240, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-avatar-ig {
  background: linear-gradient(135deg, #f09433, #dc2743);
  border-color: rgba(224, 39, 67, 0.4);
}

.account-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.account-username {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
}

.account-displayname {
  font-size: 0.85rem;
}

.account-empty {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
}

.account-empty .empty-icon {
  margin-bottom: 0.75rem;
  opacity: 0.3;
}

.account-empty p {
  margin: 0;
  font-size: 0.9rem;
}

.account-card-footer {
  padding: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

.btn-connect {
  flex: 1;
  padding: 0.9rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.btn-connect-x {
  background: linear-gradient(135deg, #1a1a2e, #2a2a3e);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-connect-x:hover {
  background: linear-gradient(135deg, #2a2a3e, #3a3a4e);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.btn-connect-ig {
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
  border: none;
}

.btn-connect-ig:hover {
  box-shadow: 0 0 20px rgba(220, 39, 67, 0.3);
  transform: translateY(-1px);
  opacity: 0.95;
}

.btn-disconnect {
  flex: 1;
  padding: 0.9rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  font-family: inherit;
  background: transparent;
  color: var(--accent-red);
  border: 1px solid rgba(255, 51, 102, 0.25);
  transition: all 0.3s ease;
}

.btn-disconnect:hover {
  background: rgba(255, 51, 102, 0.1);
  border-color: rgba(255, 51, 102, 0.4);
}

/* Loading spinner inside button */
.btn-connect.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-connect.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Info Banner */
.info-banner {
  background: rgba(0, 240, 255, 0.03);
  border: 1px solid rgba(0, 240, 255, 0.1);
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
}

/* Responsive */
@media (max-width: 900px) {
  .account-grid {
    grid-template-columns: 1fr;
  }
}