:root {
  /* Premium Dark Theme Colors */
  --bg-color: #0f172a;
  --surface-color: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --accent-color: #8b5cf6;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --error-color: #ef4444;
  --success-color: #10b981;
  
  /* System Fonts for GDPR compliance (no Google Fonts API calls) */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Typography */
h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

p {
  color: var(--text-secondary);
}

/* Views Management */
.view {
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.view.active {
  display: block;
  opacity: 1;
  animation: fadeIn 0.5s ease forwards;
}

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

.hidden {
  display: none !important;
}

/* Glassmorphism Components */
.glass-card {
  background: var(--surface-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
}

/* Login View */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#login-view .glass-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.subtitle {
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* Forms */
.input-group {
  margin-bottom: 1.5rem;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

input[type="password"]:focus,
input[type="text"]:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-select {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
}

.form-select option {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  gap: 0.5rem;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
  width: 100%;
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -10px rgba(139, 92, 246, 0.5);
}

.btn.outline {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.btn.outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.full-width {
  width: 100%;
}

.error-text {
  color: var(--error-color);
  margin-top: 1rem;
  font-size: 0.875rem;
}

.dsgvo-notice {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Dashboard */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header .logo {
  margin: 0;
  justify-content: flex-start;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Upload Section */
.upload-section {
  margin-bottom: 3rem;
}

.upload-section h3 {
  margin-bottom: 1.5rem;
}

.file-drop-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  max-width: 100%;
  padding: 2rem;
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
  background: rgba(15, 23, 42, 0.3);
  margin-bottom: 1rem;
  cursor: pointer;
}

.file-drop-area:hover, .file-drop-area.drag-over {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
}

.fake-btn {
  background: var(--surface-color);
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

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

.file-input {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  cursor: pointer;
  opacity: 0;
}

#preview-container {
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

#image-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#upload-status {
  margin-top: 1rem;
  text-align: center;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

#upload-status.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

#upload-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Gallery Section */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.gallery-header h3 {
  margin-bottom: 0;
}

.filter-select {
  width: auto;
  min-width: 150px;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 0;
}

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

.gallery-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--surface-color);
  border: 1px solid var(--glass-border);
  transition: var(--transition);
}

.gallery-item:hover {
  transform: scale(1.02);
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.download-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  padding: 1rem;
  opacity: 0;
  transition: var(--transition);
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.gallery-item:hover .download-overlay {
  opacity: 1;
}

.download-btn {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: var(--transition);
}

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

.delete-btn {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-left: 0.5rem;
}

.delete-btn:hover {
  background: var(--error-color);
  color: white;
}

.category-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  pointer-events: none;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
  }
  
  .glass-card {
    padding: 1.5rem;
  }
  
  .container {
    padding: 1rem 0.5rem;
  }

  /* Immobile: always show download button slightly visible to indicate it's there */
  .download-overlay {
    opacity: 1;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  }
}

/* --- New Multi-Select & Custom Category Styles --- */

.custom-cat-input {
  margin-top: 0.5rem;
  width: 100%;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.3);
  max-height: 200px;
  overflow-y: auto;
}

.preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.mt-2 { margin-top: 0.5rem; }
.text-sm { font-size: 0.875rem; padding: 0.5rem 1rem; }

.gallery-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.selection-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--primary-color);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.selection-action-bar .action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn.sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn.delete-btn-solid {
  background: var(--error-color);
  color: white;
  border: none;
}

.btn.delete-btn-solid:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Selectable gallery items */
.gallery-item.selectable {
  cursor: pointer;
}

.gallery-item.selectable::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  transition: var(--transition);
  pointer-events: none;
}

.gallery-item.selectable:hover::after {
  border-color: rgba(255, 255, 255, 0.5);
}

.gallery-item.selected::after {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.2);
}

.gallery-item.selected .category-badge {
  background: var(--primary-color);
}
