/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --transition: 0.3s ease;
}

/* ── Dark theme (default) ─────────────────────────────────── */
[data-theme="dark"] {
  --bg: #1C1C1E;
  --bg-card: #2C2C2E;
  --border-card: #3C3C3E;
  --text-primary: #F5F0EB;
  --text-secondary: #A0A0A0;
  --gold: #C9A96E;
  --gold-bg: rgba(201,169,110,0.10);
  --overlay: rgba(0,0,0,0.6);
  --input-bg: #3C3C3E;
  --input-border: #4C4C4E;
  --category-label: #C9A96E;
}

/* ── Light theme ──────────────────────────────────────────── */
[data-theme="light"] {
  --bg: #F5F0EB;
  --bg-card: #FFFFFF;
  --border-card: #E0DCD5;
  --text-primary: #2D2A26;
  --text-secondary: #8A8580;
  --gold: #C9A96E;
  --gold-bg: rgba(201,169,110,0.10);
  --overlay: rgba(0,0,0,0.4);
  --input-bg: #F0EDE8;
  --input-border: #D5D0CA;
  --category-label: #8B7355;
}

/* ── Color palette for initials ───────────────────────────── */
.color-gold   { --ic-bg: rgba(201,169,110,0.15); --ic-fg: #C9A96E; }
.color-blue   { --ic-bg: rgba(55,138,221,0.15);  --ic-fg: #378ADD; }
.color-green  { --ic-bg: rgba(29,158,117,0.15);  --ic-fg: #1D9E75; }
.color-purple { --ic-bg: rgba(83,74,183,0.15);   --ic-fg: #534AB7; }
.color-coral  { --ic-bg: rgba(216,90,48,0.15);   --ic-fg: #D85A30; }
.color-pink   { --ic-bg: rgba(212,83,126,0.15);  --ic-fg: #D4537E; }
.color-amber  { --ic-bg: rgba(186,117,23,0.15);  --ic-fg: #BA7517; }

/* ── Body ─────────────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; right: 0;
  padding: 16px 24px;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Theme toggle icons */
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 100px 24px 48px;
}

.hero-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300;
  font-size: 36px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  transition: color var(--transition);
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 300;
  transition: color var(--transition);
}

.hero-line {
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 24px auto 0;
}

/* ── Tools container ──────────────────────────────────────── */
.tools-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

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

.category-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--category-label);
  margin-bottom: 20px;
  padding-left: 4px;
}

/* ── Cards grid ───────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding-top: 80px; }
}

/* ── Tool card ────────────────────────────────────────────── */
.tool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.tool-card:active {
  transform: scale(0.98);
}

.tool-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Icon / initials */
.tool-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 18px;
  background: var(--ic-bg);
  color: var(--ic-fg);
  transition: background var(--transition);
}

.tool-icon img {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  padding: 4px;
}

/* ── Medallion (round, brand-colored background) ─────────── */
.tool-medallion {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tool-card:hover .tool-medallion {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.tool-medallion img {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.tool-name {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
}

.tool-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: center;
  transition: color var(--transition);
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: auto;
  transition: color var(--transition);
}

/* ── Admin panel ──────────────────────────────────────────── */
.admin-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 0.2s ease;
}
.admin-overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.admin-panel {
  width: 450px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s ease;
  overflow: hidden;
}

@media (max-width: 768px) {
  .admin-panel { width: 100vw; }
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-card);
}

.admin-header h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 400;
  font-size: 22px;
}

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

.admin-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

/* ── Admin sections ───────────────────────────────────────── */
.admin-section {
  margin-bottom: 28px;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gold);
}

.admin-tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--bg-card);
  transition: border-color 0.2s;
}

.admin-tool-item:hover {
  border-color: var(--gold);
}

.admin-tool-info {
  flex: 1;
  min-width: 0;
}

.admin-tool-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-tool-url {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-tool-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-sm {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--gold); color: var(--gold); }
.btn-sm.danger:hover { border-color: #C4655A; color: #C4655A; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  animation: fadeIn 0.2s ease;
}

.modal h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 400;
  font-size: 20px;
  margin-bottom: 4px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

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

/* ── Form edit modal ──────────────────────────────────────── */
.form-modal {
  max-width: 420px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.btn-gold {
  background: var(--gold);
  color: #fff;
}
.btn-gold:hover { background: #B8984E; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-card);
  color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

.btn-add {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-add:hover { border-color: var(--gold); }

/* ── Input ────────────────────────────────────────────────── */
.input, .select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--gold);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23A0A0A0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.error-text {
  color: #C4655A;
  font-size: 12px;
  margin-top: 6px;
}

/* ── Confirm dialog ───────────────────────────────────────── */
.confirm-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 12px 0 0;
}

/* ── Scrollbar ────────────────────────────────────────────── */
.admin-content::-webkit-scrollbar { width: 4px; }
.admin-content::-webkit-scrollbar-track { background: transparent; }
.admin-content::-webkit-scrollbar-thumb { background: var(--border-card); border-radius: 4px; }

/* ── Login screen ─────────────────────────────────────────── */
.login-container {
  max-width: 400px;
  margin: 15vh auto;
  padding: 2rem;
  text-align: center;
}

.login-theme-toggle {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 50;
}

.login-divider {
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 16px auto 0;
}

.login-form {
  margin-top: 2rem;
}

.login-field {
  margin-bottom: 1rem;
  text-align: left;
}

.login-field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 500;
}

.login-button {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  margin-top: 0.5rem;
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  color: #C4655A;
  font-size: 13px;
  margin-bottom: 0.5rem;
  text-align: left;
}

@media (max-width: 768px) {
  .login-container {
    margin-top: 10vh;
    padding: 1.5rem;
  }
}

/* ── Chatbot Jarvis Icon ──────────────────────────────────── */
@keyframes chatbot-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(0, 180, 255, 0.3)); }
  50% { filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.6)); }
}

@keyframes chatbot-pupil-glow {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.chatbot-btn {
  width: 40px; height: 40px;
  background: none;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.chatbot-btn:hover {
  border-color: #00b4ff;
  background: rgba(0, 180, 255, 0.08);
}

.chatbot-btn svg {
  animation: chatbot-pulse 3s ease-in-out infinite;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.chatbot-btn:hover svg {
  animation: none;
  filter: drop-shadow(0 0 14px rgba(0, 212, 255, 0.8));
  transform: scale(1.15);
}

.chatbot-btn .chatbot-pupil {
  animation: chatbot-pupil-glow 2s ease-in-out infinite;
}
