/* Viktor Key - Identity Hub Styles */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-card: #1a1a1a;
  --bg-hover: #252525;
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --border: #27272a;
  --border-light: #3f3f46;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Loading Spinner */
#loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

/* Auth Gate */
#auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 3rem;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-logo { font-size: 3rem; margin-bottom: 1rem; }

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff 0%, #a855f7 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: #fff;
  color: #1f1f1f;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.google-btn:hover { background: #f3f4f6; transform: translateY(-2px); }

.login-note { margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-muted); }

/* Header */
.header {
  display: flex;
  justify-content: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(10px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1000px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-icon { font-size: 1.5rem; }

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

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

.btn-signout {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-signout:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Main Content */
.main-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
}

/* Dashboard Sections */
.dashboard-section {
  margin-bottom: 2.5rem;
}

.section-header {
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Profile Card */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  flex-shrink: 0;
}

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

.profile-info {
  flex: 1;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.profile-email {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.profile-uid {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: monospace;
  margin-top: 0.5rem;
}

/* Sites Grid */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  transition: all 0.2s;
}

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

.site-icon { font-size: 2rem; }

.site-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.site-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  background: var(--accent-glow);
  color: var(--accent-hover);
}

.site-status.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

/* API Keys */
.api-keys-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.api-key-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.api-key-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.api-key-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  background: var(--accent-glow);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.api-key-info { flex: 1; }

.api-key-name {
  font-weight: 600;
  display: block;
  margin-bottom: 0.125rem;
}

.api-key-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.api-key-input-group {
  display: flex;
  gap: 0.5rem;
}

.api-key-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.875rem;
}

.api-key-input:focus {
  outline: none;
  border-color: var(--accent);
}

.api-key-input::placeholder {
  color: var(--text-muted);
}

.btn-toggle-visibility {
  padding: 0.75rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-visibility:hover {
  background: var(--border);
}

.eye-icon {
  font-size: 1rem;
}

.btn-save {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save:hover {
  background: var(--accent-hover);
}

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

.api-key-status {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

.api-key-status.success { color: var(--success); }
.api-key-status.error { color: var(--error); }
.api-key-status.loading { color: var(--text-muted); }

/* AI Chat Widget */
.chat-widget {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
  z-index: 999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.chat-icon { font-size: 1.25rem; }

.chat-header span:nth-child(2) {
  flex: 1;
  font-weight: 600;
}

.chat-toggle {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.chat-widget.collapsed .chat-toggle {
  transform: rotate(180deg);
}

.chat-widget.collapsed .chat-body {
  display: none;
}

.chat-body {
  display: flex;
  flex-direction: column;
  height: 350px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--bg-primary);
  border-bottom-left-radius: 0.25rem;
}

.chat-message p { margin: 0; }

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.chat-input-area input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.chat-input-area input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input-area button {
  padding: 0.75rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: 0.5rem;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.chat-input-area button:hover {
  background: var(--accent-hover);
}

.chat-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-no-key {
  padding: 2rem 1rem;
  text-align: center;
}

.chat-no-key p {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.chat-no-key-hint {
  font-size: 0.85rem;
  color: var(--accent);
}

.chat-typing {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border-radius: 1rem;
  width: fit-content;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 1rem; }
  .main-content { padding: 5rem 1rem 1rem; }
  .profile-card { flex-direction: column; text-align: center; }
  .sites-grid { grid-template-columns: repeat(2, 1fr); }
  .api-key-input-group { flex-wrap: wrap; }
  .api-key-input { min-width: 100%; }
}

@media (max-width: 480px) {
  .sites-grid { grid-template-columns: 1fr; }
}

/* Viktor Navigation Styles */
.nav-categories {
  display: flex;
  gap: 0.5rem;
}

.nav-category {
  position: relative;
}

.nav-category-btn {
  background: transparent;
  border: 1px solid #333;
  color: #888;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.nav-category-btn:hover {
  border-color: #6366f1;
  color: #fff;
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.5rem;
  min-width: 160px;
  z-index: 100;
  margin-top: 0.25rem;
}

.nav-category:hover .nav-dropdown {
  display: block;
}

.nav-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: #ccc;
  text-decoration: none;
  border-radius: 4px;
}

.nav-dropdown a:hover {
  background: #333;
  color: #fff;
}

.nav-dropdown a.active {
  color: #6366f1;
}

.nav-icon {
  font-size: 1rem;
}

#main-nav {
  margin-left: auto;
  margin-right: 1rem;
}

@media (max-width: 768px) {
  .nav-categories {
    display: none;
  }
}
