/* OpenColorTables - Clean Modern UI */

:root {
  --bg-primary: #0a0a0b;
  --bg-secondary: #141417;
  --bg-tertiary: #1c1c21;
  --bg-hover: #252529;
  --bg-card: #18181b;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #27272a;
  --border-light: #3f3f46;
  --success: #22c55e;
  --error: #ef4444;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* Container */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ==================== NAVBAR ==================== */
.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 32px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.navbar-logo {
  width: 32px;
  height: 32px;
}

.navbar-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

#auth-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}

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

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

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

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-google {
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
}

.btn-google:hover {
  background: #f5f5f5;
}

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

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

/* ==================== USER MENU ==================== */
.user-menu {
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.user-avatar:hover {
  border-color: var(--border-light);
}

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

.user-avatar-placeholder {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 180px;
  padding: 6px;
  display: none;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.user-dropdown.show {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.user-dropdown-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.user-dropdown-item svg {
  opacity: 0.7;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* ==================== LAYOUT ==================== */
.page-layout {
  display: flex;
  gap: 24px;
  padding: 24px 0;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
}

.sidebar-sticky {
  position: sticky;
  top: 80px;
}

.main-content {
  flex: 1;
  min-width: 0;
}

/* ==================== SIDEBAR ==================== */
.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-radius: 6px;
  transition: all 0.15s;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.sidebar-link.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.sidebar-link-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================== PAGE HEADER ==================== */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ==================== TOOLBAR ==================== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

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

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.select {
  padding: 8px 32px 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.875rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* ==================== PALETTE CARD ==================== */
.palette-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

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

.palette-preview {
  height: 160px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.palette-preview img,
.palette-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.palette-preview.generating {
  position: relative;
}

.palette-preview .preview-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--text-muted);
  font-size: 0.625rem;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
}

.palette-body {
  padding: 14px;
}

.palette-name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

.palette-author {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.palette-author:hover {
  color: var(--text-primary);
}

.palette-author-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
}

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

.palette-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.palette-actions {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
}

.palette-actions .btn {
  flex: 1;
}

/* ==================== HERO ==================== */
.hero {
  text-align: center;
  padding: 80px 20px 60px;
  border-bottom: 1px solid var(--border);
}

.hero-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto 28px;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.stat {
  text-align: center;
}

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

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==================== SECTIONS ==================== */
.section {
  padding: 40px 0;
  border-bottom: 1px solid var(--border);
}

.section:last-of-type {
  border-bottom: none;
}

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

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
}

/* ==================== AUTH PAGES ==================== */
.auth-page {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
}

.form-input {
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9375rem;
}

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

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

.form-error {
  color: var(--error);
  font-size: 0.8125rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ==================== UPLOAD PAGE ==================== */
.upload-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 20px;
}

.upload-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}

.upload-header {
  margin-bottom: 24px;
}

.upload-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.dropzone-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--text-muted);
}

.dropzone-text {
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.file-preview-icon {
  color: var(--accent);
}

.file-preview-info {
  flex: 1;
  min-width: 0;
}

.file-preview-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-preview-remove {
  padding: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
}

.file-preview-remove:hover {
  color: var(--error);
}

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

.palette-preview-box {
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.palette-preview-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==================== PROFILE PAGE ==================== */
.profile-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

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

.profile-avatar-placeholder {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-muted);
}

.profile-info {
  flex: 1;
}

.profile-info h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.profile-info p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.profile-stats {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

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

.profile-stat strong {
  color: var(--text-primary);
  font-weight: 600;
}

.profile-actions {
  flex-shrink: 0;
}

/* ==================== TABS ==================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
}

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

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

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  padding: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

/* ==================== LOADING ==================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 11, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

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

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

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  animation: slideIn 0.2s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

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

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

/* ==================== FOOTER ==================== */
.footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar { display: none; }

  .page-layout {
    padding: 16px 0;
  }

  .navbar-nav { display: none; }

  .hero { padding: 48px 20px 40px; }
  .hero-title { font-size: 1.5rem; }
  .hero-logo { width: 64px; height: 64px; }

  .stats {
    gap: 24px;
    flex-wrap: wrap;
  }

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
  }

  .profile-actions {
    margin-top: 12px;
  }

  .profile-stats {
    justify-content: center;
  }
}
