:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --bg-dark: #0f172a;
  --bg-panel: #1e293b;
  --bg-card: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #475569;
  --danger: #ef4444;
  --success: #10b981;
}

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

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

.hidden { display: none !important; }

/* Screens */
.screen {
  height: 100vh;
  width: 100vw;
  display: flex;
}

#login-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--bg-dark), #1e1b4b);
}

.login-card {
  background: var(--bg-panel);
  padding: 3rem 2rem;
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card .logo {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

button {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 0.95rem;
}

button.primary {
  background: var(--primary);
  color: white;
}
button.primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

button.secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--border); }

button.danger {
  background: var(--danger);
  color: white;
}
button.danger:hover { filter: brightness(1.1); }

button.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Layout */
.sidebar {
  width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.nav-section {
  padding: 1rem 1.5rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.nav-btn {
  width: 100%;
  text-align: left;
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--text-muted);
  border-radius: 0;
  font-weight: 500;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  border-right: 3px solid var(--primary);
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.link-btn {
  background: none;
  color: var(--primary);
  padding: 0;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; background: none; }

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
}

.topbar {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.topbar h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.view-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* Dashboard & Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

.stat-card h3 {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
}

.card {
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

.card.bg-hint {
  background: rgba(79, 70, 229, 0.1);
  border-color: var(--primary);
  margin-bottom: 1.5rem;
}

.actions { display: flex; gap: 1rem; margin-top: 1rem; }

.preview {
  background: var(--bg-dark);
  padding: 1rem;
  border-radius: 0.5rem;
  margin-top: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  border: 1px solid var(--border);
}

/* Tables */
.table-wrap {
  background: var(--bg-panel);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  overflow: hidden;
}

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

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.td-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 0.25rem;
  border-radius: 0.25rem;
}
.icon-btn:hover { color: var(--text-main); background: var(--bg-card); }

/* Forms & Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-panel);
  width: 100%;
  max-width: 500px;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-content.modal-lg {
  max-width: 800px;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { font-size: 1.25rem; }

#modal-form, .asset-picker-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.checkbox-label input { width: auto; }

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background: var(--bg-card);
  border-radius: 0 0 1rem 1rem;
}

/* Asset Picker */
.asset-picker-input {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-dark);
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px dashed var(--border);
}

.asset-picker-input .preview-box {
  width: 60px;
  height: 60px;
  background: var(--bg-card);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 2rem;
}
.asset-picker-input .preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.assets-grid.small-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.asset-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.asset-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.asset-preview {
  height: 100px;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.asset-preview img, .asset-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-info {
  padding: 0.5rem;
  font-size: 0.75rem;
}
.asset-info .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.asset-info .meta {
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.asset-picker-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  z-index: 200;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.error { background: var(--danger); }

/* Utilities */
.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-main);
}
.badge.premium { background: #f59e0b; color: #fff; }
.badge.active { background: var(--success); color: #fff; }
.badge.inactive { background: var(--border); color: #fff; }
.text-muted { color: var(--text-muted); }
