/* TrendAI Brand-Compliant Styles — Dark Theme Default */

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

:root {
  /* Primary */
  --red: #d71920;
  --red-dark: #b81419;
  --amber: #ff9500;
  --signal: #2e0fe4;
  --black: #000000;
  --white: #ffffff;

  /* Dark theme surfaces */
  --bg: #000000;
  --card: #0a0a0a;
  --input-bg: #111111;
  --border: #1a1a1a;
  --input-border: #333333;

  /* Text */
  --text-primary: #e5e5e5;
  --text-secondary: #888888;
  --text-muted: #666666;
  --text-placeholder: #444444;

  /* Status */
  --success: #22c55e;
  --warning: #ff9500;
  --error: #ff6b6f;

  /* Gradient */
  --gradient: linear-gradient(135deg, #d71920 0%, #ff9500 100%);
}

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

body {
  font-family: 'Work Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 400;
  min-height: 100vh;
}

/* --- Layout --- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header img { height: 32px; }

.sidebar-nav { flex: 1; padding: 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--input-bg); color: var(--text-primary); }
.nav-item.active { background: var(--red); color: var(--white); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--red);
  color: var(--white);
}

.badge.user-badge { background: var(--input-border); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.page-header {
  padding: 24px 32px 0;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.page-content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--gradient);
  color: var(--white);
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
}
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}
.btn-danger:hover { background: var(--error); color: var(--white); }

.btn-sm { padding: 6px 12px; font-size: 11px; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--red);
}

input::placeholder, textarea::placeholder {
  color: var(--text-placeholder);
}

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

/* --- Login page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
}

.login-card .logo {
  display: block;
  margin: 0 auto 32px;
  height: 40px;
}

.login-card h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  text-align: center;
  margin-bottom: 24px;
}

.login-card .btn { width: 100%; margin-top: 8px; }

.error-msg {
  background: rgba(255, 107, 111, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}

.error-msg.visible { display: block; }

/* --- Generator page --- */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  height: 100%;
}

.gen-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.gen-panel h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 16px;
}

.prompt-area { flex: 1; display: flex; flex-direction: column; }
.prompt-area textarea { flex: 1; min-height: 160px; }
.prompt-actions { margin-top: 12px; display: flex; gap: 8px; }

.result-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.result-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.result-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.result-text {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  white-space: pre-wrap;
}

/* --- Violations banner --- */
.violations {
  background: rgba(255, 149, 0, 0.1);
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 12px;
  width: 100%;
}

.violations h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warning);
  margin-bottom: 8px;
}

.violations ul {
  list-style: none;
  padding: 0;
}

.violations li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.violations li::before {
  content: "!";
  position: absolute;
  left: 0;
  color: var(--warning);
  font-weight: 700;
}

/* --- Admin panel --- */
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.users-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.users-table tr:hover { background: var(--input-bg); }

.actions { display: flex; gap: 6px; }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  display: none;
}

.modal-overlay.visible { display: flex; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
}

.modal h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* --- History --- */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.history-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.history-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.history-card-body {
  padding: 14px;
}

.history-card-body p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.history-card-body .timestamp {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Brand Asset Picker --- */
.brand-picker {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.brand-picker-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  cursor: default;
}

.asset-count {
  font-size: 10px;
  color: var(--red);
  font-weight: 700;
}

.brand-assets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.brand-asset {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--input-bg);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.brand-asset:hover { border-color: var(--input-border); }

.brand-asset.selected {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}

.brand-asset img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-asset .asset-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.8);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 3px 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-asset.selected .asset-name { color: var(--red); }

.brand-asset .check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--red);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.brand-asset.selected .check { display: flex; }

/* --- Violation Alert (pre-generation) --- */
.violation-alert {
  background: rgba(255, 149, 0, 0.08);
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 12px;
  animation: alertFadeIn 0.2s ease;
}

@keyframes alertFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.violation-alert-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.violation-alert ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.violation-alert li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0 3px 16px;
  position: relative;
}

.violation-alert li::before {
  content: "!";
  position: absolute;
  left: 0;
  color: var(--warning);
  font-weight: 700;
  font-size: 11px;
}

.violation-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* --- Loading spinner --- */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Change password banner --- */
.pw-banner {
  background: rgba(255, 149, 0, 0.1);
  border: 1px solid var(--warning);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  display: none;
}

.pw-banner.visible { display: flex; }

.pw-banner span {
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
}

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

@media (max-width: 640px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { display: flex; gap: 4px; padding: 8px; }
  .sidebar-header { padding: 12px 16px; }
  .sidebar-footer { display: none; }
}

/* --- Logout button --- */
.btn-logout {
  background: none;
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 10px;
  width: 100%;
}

.btn-logout:hover { border-color: var(--error); color: var(--error); }
