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

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --success: #00d2a0;
  --error: #ff6b6b;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== Layout ===== */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  text-align: center;
  margin-bottom: 2.5rem;
}

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

.logo svg {
  color: var(--accent);
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

/* ===== Upload Area ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-secondary);
  position: relative;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
  box-shadow: 0 0 30px var(--accent-glow);
}

.upload-area.dragover {
  transform: scale(1.01);
}

.upload-icon {
  margin-bottom: 1rem;
  color: var(--accent);
}

.upload-area h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.upload-area p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.browse-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.upload-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
}

/* ===== Progress ===== */
.progress-container {
  margin-top: 1.5rem;
  text-align: center;
}

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

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

.progress-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ===== Result Area ===== */
.result-area {
  margin-top: 2rem;
  animation: fadeIn 0.4s ease;
}

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

.result-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.result-preview img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.result-links h3 {
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 1.15rem;
}

.link-group {
  margin-bottom: 0.75rem;
}

.link-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.link-row {
  display: flex;
  gap: 0.5rem;
}

.link-row input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none;
  transition: border-color var(--transition);
}

.link-row input:focus {
  border-color: var(--accent);
}

.link-row button,
.copy-btn {
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-width: 70px;
}

.link-row button:hover,
.copy-btn:hover {
  background: var(--accent-hover);
}

.link-row button.copied,
.copy-btn.copied {
  background: var(--success);
}

.upload-another-btn {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.75rem;
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.upload-another-btn:hover {
  background: var(--accent);
  color: white;
}

/* ===== Recent Uploads ===== */
.recent-section {
  margin-top: 3rem;
}

.recent-section h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

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

.recent-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
  position: relative;
}

.recent-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

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

/* ===== View Page ===== */
.view-page {
  max-width: 900px;
}

.view-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.view-image-wrapper {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
}

.view-image {
  max-width: 100%;
  max-height: 600px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.view-links {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.view-links h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* ===== Footer ===== */
footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===== Error Message ===== */
.error-message {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container {
    padding: 1.25rem 1rem;
  }

  .upload-area {
    padding: 2rem 1.25rem;
  }

  .recent-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

/* ===== Tab Navigation ===== */
.tab-nav {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(108, 92, 231, 0.05);
}

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

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== Group Upload Form ===== */
.group-upload-form .form-field {
  margin-bottom: 1rem;
}

.group-upload-form .form-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.group-upload-form .form-field input[type="text"] {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}

.group-upload-form .form-field input[type="text"]:focus {
  border-color: var(--accent);
}

.group-upload-form .form-field input[type="text"]::placeholder {
  color: var(--text-muted);
}

/* ===== Selected Files List ===== */
.selected-files {
  margin-top: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.selected-files h4 {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.file-list {
  max-height: 200px;
  overflow-y: auto;
}

.file-list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.file-list-item:last-child {
  border-bottom: none;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.file-size {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.file-remove {
  background: none;
  border: none;
  color: var(--error);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: opacity var(--transition);
}

.file-remove:hover {
  opacity: 0.7;
}

.upload-group-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

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

/* ===== Group Result ===== */
.group-result {
  animation: fadeIn 0.4s ease;
}

.group-result-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.group-result-header h3 {
  margin-bottom: 0.25rem;
}

.group-result-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.group-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
  margin-bottom: 1rem;
}

/* ===== Categories Section ===== */
.categories-section {
  margin-top: 3rem;
}

.categories-section h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
}

.category-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.category-card-info h4 {
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.category-card-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.category-card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== Category View Page ===== */
.category-view {
  margin-top: 1rem;
}

.category-header {
  margin-bottom: 1.5rem;
}

.category-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.category-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

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

.category-image-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
  display: block;
}

.category-image-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

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