/* Nordic Portfolio Design System */
:root {
  /* Light mode (default) */
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f5;
  --bg-hover: #f0f0f0;
  --text-primary: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --border-color: #e5e5e5;
  --border-hover: #d4d4d4;
  --accent: #0a0a0a;
  --accent-hover: #262626;
  --error: #ef4444;
  --success: #22c55e;
}

body.dark {
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-tertiary: #27272a;
  --bg-hover: #3f3f46;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border-color: #27272a;
  --border-hover: #3f3f46;
  --accent: #fafafa;
  --accent-hover: #e4e4e7;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Control Buttons Container */
.controls-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 8px;
  z-index: 1000;
}

.control-btn {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

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

.control-btn svg {
  width: 16px;
  height: 16px;
}

/* Legacy support for existing toggle classes */
.theme-toggle,
.fullscreen-toggle {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s ease;
  position: fixed;
  z-index: 1000;
}

.theme-toggle {
  top: 24px;
  right: 24px;
}

.fullscreen-toggle {
  top: 24px;
  right: 68px;
}

.theme-toggle:hover,
.fullscreen-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.theme-toggle svg,
.fullscreen-toggle svg {
  width: 16px;
  height: 16px;
}

/* ==================== AUTH SCREEN ==================== */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Decorative background images */
.auth-bg-image {
  position: absolute;
  border-radius: 24px;
  opacity: 0.08;
  filter: blur(1px) saturate(0.8);
  pointer-events: none;
  transition: opacity 0.3s ease;
  object-fit: cover;
}

body.dark .auth-bg-image {
  opacity: 0.06;
  filter: blur(1px) saturate(0.6);
}

.auth-bg-1 {
  width: 280px;
  height: 200px;
  top: 8%;
  left: 5%;
  transform: rotate(-6deg);
}

.auth-bg-2 {
  width: 220px;
  height: 160px;
  top: 12%;
  right: 8%;
  transform: rotate(4deg);
}

.auth-bg-3 {
  width: 240px;
  height: 180px;
  bottom: 15%;
  right: 6%;
  transform: rotate(-3deg);
}

.auth-bg-4 {
  width: 200px;
  height: 150px;
  bottom: 10%;
  left: 8%;
  transform: rotate(5deg);
}

@media (max-width: 900px) {
  .auth-bg-image {
    opacity: 0.05;
  }
  .auth-bg-1, .auth-bg-2 {
    width: 160px;
    height: 120px;
  }
  .auth-bg-3, .auth-bg-4 {
    display: none;
  }
}

.auth-content {
  width: 100%;
  max-width: 400px;
  padding: 48px 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.auth-content h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 8px;
}

.auth-content .tagline {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 32px;
}

.auth-content .tagline-sub {
  font-size: 13px;
  color: var(--text-muted);
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-form input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s ease;
}

#auth-form input:focus {
  border-color: var(--text-muted);
  background: var(--bg-secondary);
}

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

#login-btn {
  width: 100%;
  padding: 12px 24px;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 500;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

#login-btn:hover {
  background: var(--accent-hover);
}

#signup-btn {
  width: 100%;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

#signup-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.error-message {
  margin-top: 16px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  color: var(--error);
  font-size: 14px;
  text-align: center;
  min-height: 0;
}

.error-message:empty {
  display: none;
}

/* ==================== DASHBOARD ==================== */
#dashboard {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-primary);
}

.dashboard-content {
  width: 100%;
  max-width: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
}

/* Dashboard Header */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border-color);
}

.dashboard-header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.logout-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* Stats Section */
.upload-section {
  padding: 28px;
  border-bottom: 1px solid var(--border-color);
}

#image-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.upload-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  border-style: solid;
  color: var(--text-primary);
}

.upload-btn input {
  display: none;
}

#upload-progress {
  margin-top: 16px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

#progress-text {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 28px;
}

.start-btn {
  grid-column: 1 / -1;
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 500;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.start-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.manage-btn {
  grid-column: 1 / -1;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.hint {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ==================== GALLERY ==================== */
#gallery {
  min-height: 100vh;
  background: var(--bg-primary);
  padding: 24px;
  overflow-y: auto;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  flex-wrap: wrap;
  gap: 16px;
}

.gallery-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

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

.gallery-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.gallery-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.delete-btn-action {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.delete-btn-action:hover:not(:disabled) {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

.back-btn-action {
  background: var(--bg-secondary);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--bg-secondary);
  transition: all 0.15s ease;
}

.gallery-item:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.gallery-item.selected {
  border-color: var(--accent);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item .checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gallery-item.selected .checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.gallery-item .checkbox::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid var(--bg-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.gallery-item.selected .checkbox::after {
  opacity: 1;
}

/* ==================== IMAGE VIEWER ==================== */
#viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  cursor: pointer;
}

#current-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}

#counter {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Viewer Controls */
.viewer-exit-btn {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-exit-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.delete-btn {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: transparent;
  color: #fff;
}

.nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 96px;
  font-size: 24px;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.6);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 50;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.back-btn {
  left: 0;
  border-radius: 0 10px 10px 0;
}

.next-btn {
  right: 0;
  border-radius: 10px 0 0 10px;
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 32px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.modal-content p {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.modal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.confirm-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.confirm-btn:hover {
  opacity: 0.9;
}

.cancel-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* ==================== LOADING ==================== */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.loader {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ==================== UTILITY ==================== */
.hidden {
  display: none !important;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
  .dashboard-content {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .auth-content {
    padding: 32px 24px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

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

  .action-buttons {
    padding: 20px;
  }

  .upload-section {
    padding: 20px;
  }
}
