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

:root {
  --bg-canvas: #000000;
  --bg-surface: #232244;
  --bg-card: #2a2950;
  --border-muted: #434173;
  --accent-primary: #635F9C;
  --text-primary: #FFFFFF;
  --text-muted: #A5A1D4;
  --text-dim: #6b68a0;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 260px;
  --header-height: 64px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--text-primary);
}

img {
  max-width: 100%;
  display: block;
}

input,
textarea,
select {
  font-family: var(--font-family);
  font-size: 0.9rem;
}

/* ─── Layout ─── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-header {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border-muted);
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ─── Navbar ─── */
.navbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-muted);
  height: var(--header-height);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-brand i {
  color: var(--accent-primary);
  font-size: 1.3rem;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 16px;
  list-style: none;
}

.navbar-links a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--text-primary);
  background: rgba(99, 95, 156, 0.15);
}

/* ─── Search Bar ─── */
.search-wrapper {
  position: relative;
  max-width: 480px;
  width: 100%;
}

.search-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.search-wrapper input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrapper input::placeholder {
  color: var(--text-dim);
}

.search-wrapper input:focus {
  border-color: var(--accent-primary);
}

/* ─── Category Section ─── */
.category-section {
  margin-bottom: 40px;
}

.category-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-title i {
  color: var(--accent-primary);
}

/* ─── Tool Cards Grid ─── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.25s;
  cursor: pointer;
  position: relative;
}

.tool-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tool-card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: rgba(99, 95, 156, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 1.2rem;
  color: var(--accent-primary);
}

.tool-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-card p {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255, 183, 77, 0.15);
  color: #FFB74D;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-card[data-premium="true"] .tool-card-badge {
  background: rgba(255, 183, 77, 0.15);
  color: #FFB74D;
}

/* ─── No Results ─── */
.no-results {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}

.no-results i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

/* ─── App Shell Layout ─── */
.app-shell {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-muted);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.app-sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-muted);
}

.app-sidebar-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.app-sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-muted);
}

.app-sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
}

.app-sidebar-search input:focus {
  border-color: var(--accent-primary);
}

.app-sidebar-tools {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.sidebar-tool-item:hover {
  background: rgba(99, 95, 156, 0.08);
  color: var(--text-primary);
}

.sidebar-tool-item.active {
  background: rgba(99, 95, 156, 0.15);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.sidebar-tool-item i {
  width: 16px;
  text-align: center;
  font-size: 0.8rem;
}

.sidebar-tool-item .premium-badge {
  margin-left: auto;
  font-size: 0.6rem;
  opacity: 0.6;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-canvas);
}

.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-surface);
  min-height: 48px;
}

.app-toolbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-toolbar-info i {
  color: var(--accent-primary);
}

.app-toolbar-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.app-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.app-viewport iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.app-ad-slot {
  border-top: 1px solid var(--border-muted);
  background: var(--bg-surface);
  padding: 12px 20px;
  text-align: center;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-ad-slot .ad-placeholder {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.app-ad-slot[data-hidden="true"] {
  display: none;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border-muted);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.btn-primary:hover {
  background: #7a75b8;
  border-color: #7a75b8;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent-primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select {
  cursor: pointer;
}

.form-group select option {
  background: var(--bg-surface);
}

/* ─── Admin Panel ─── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

.admin-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-muted);
  padding: 24px 16px;
}

.admin-sidebar h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.admin-sidebar .stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.admin-sidebar .stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.admin-sidebar .stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

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

.admin-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
}

.admin-form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 28px;
  max-width: 600px;
}

.admin-tools-list {
  margin-top: 32px;
}

.admin-tools-list h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.admin-tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.admin-tool-row .tool-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-tool-row .tool-info i {
  color: var(--accent-primary);
}

.admin-tool-row .tool-info .tool-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.admin-tool-row .tool-info .tool-path {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.admin-tool-row .tool-actions {
  display: flex;
  gap: 8px;
}

.admin-login-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height));
  padding: 24px;
}

.admin-login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.admin-login-card i {
  font-size: 2.5rem;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.admin-login-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.admin-login-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ─── Toast / Notification ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success {
  border-color: #4CAF50;
}

.toast.success i {
  color: #4CAF50;
}

.toast.error {
  border-color: #EF5350;
}

.toast.error i {
  color: #EF5350;
}

.toast.info {
  border-color: var(--accent-primary);
}

.toast.info i {
  color: var(--accent-primary);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Loading ─── */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-dim);
  gap: 12px;
}

.loading-spinner .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-muted);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ─── Utility ─── */
.text-muted {
  color: var(--text-muted);
}

.text-dim {
  color: var(--text-dim);
}

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

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.flex {
  display: flex;
}

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

.gap-2 {
  gap: 8px;
}

.gap-4 {
  gap: 16px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    min-width: unset;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-muted);
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border-muted);
  }

  .tools-grid {
    grid-template-columns: 1fr;
  }

  .navbar .container {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .navbar {
    height: auto;
  }

  .search-wrapper {
    max-width: 100%;
  }

  .admin-content {
    padding: 20px;
  }

  .admin-form-card {
    max-width: 100%;
  }
}
