/* Simple Image Gallery - Ultra-Clean Minimalist Dark Theme */
:root {
  --bg-main: #09090b;
  --bg-card: #121215;
  --bg-card-hover: #18181f;
  --bg-input: #0e0e12;
  --bg-overlay: rgba(5, 5, 7, 0.82);

  --border: #202026;
  --border-hover: #32323d;
  --border-focus: #4f46e5;

  --text-primary: #f4f4f6;
  --text-secondary: #82828e;
  --text-muted: #52525c;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-cyan: #38bdf8;
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header Minimalis */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon-nav {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

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

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Upload Section */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drop-zone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  padding: 1.5rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.drop-zone:hover, .drop-zone:focus-visible {
  border-color: var(--accent-primary);
  background-color: var(--bg-card-hover);
}

.drop-zone.dragover {
  border-color: var(--accent-cyan);
  background-color: rgba(56, 189, 248, 0.08);
}

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

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.drop-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.drop-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.drop-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

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

/* Upload Progress */
.upload-progress-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: fadeIn 0.15s ease-out;
}

.upload-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.upload-progress-status {
  font-weight: 500;
  color: var(--text-secondary);
}

.upload-progress-percent {
  font-weight: 600;
  color: var(--accent-cyan);
}

.progress-bar-track {
  width: 100%;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #38bdf8);
  border-radius: 9999px;
  transition: width 0.15s ease-out;
}

/* Gallery Section */
.gallery-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.gallery-title-group h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.badge {
  font-size: 0.725rem;
  font-weight: 500;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
}

/* Gallery Grid (Square 1:1 Thumbnails) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.gallery-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.gallery-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background-color: #141419;
  transition: transform 0.25s ease;
}

.gallery-card:hover .gallery-thumbnail {
  transform: scale(1.03);
}

/* Hover Overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(9, 9, 11, 0.85) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.6rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.gallery-card:hover .card-overlay,
.gallery-card:focus-within .card-overlay {
  opacity: 1;
}

.card-bottom-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.card-filename {
  font-size: 0.725rem;
  font-weight: 500;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.card-action-btns {
  display: flex;
  gap: 0.25rem;
}

.action-icon-btn {
  background-color: rgba(20, 20, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.action-icon-btn:hover {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.action-icon-btn.btn-delete-card:hover {
  background-color: var(--accent-danger);
  border-color: var(--accent-danger);
}

/* Skeleton Loading */
.skeleton-card {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, #121215 25%, #1c1c22 50%, #121215 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border: 1px solid var(--border);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Empty State */
.empty-state {
  padding: 3.5rem 1rem;
  text-align: center;
  background-color: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1;
}

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

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

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

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

.btn-danger {
  background-color: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background-color: var(--accent-danger);
  color: #ffffff;
}

.btn-full {
  width: 100%;
  padding: 0.65rem 1rem;
}

/* Modals & Popups */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

/* Popup Minimalis (Access Key & Rename) */
.modal-card.modal-popup {
  max-width: 380px;
}

.modal-header-minimal {
  padding: 1rem 1.25rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popup-title-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.popup-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: rgba(79, 70, 229, 0.15);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header-minimal h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.modal-form-minimal {
  padding: 0.75rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-desc-minimal {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.modal-error {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: center;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%, 75% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
}

.input-group-relative {
  position: relative;
  width: 100%;
}

.input-minimal {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 2.4rem 0.65rem 0.85rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.input-minimal:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
}

.btn-eye-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.btn-eye-toggle:hover {
  color: var(--text-primary);
}

.modal-button-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Preview Modal Lightbox */
.modal-card.modal-preview {
  max-width: 680px;
  max-height: 94vh;
}

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

.modal-title-group {
  overflow: hidden;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.modal-filename {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-inline-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

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

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

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 0.4rem;
  line-height: 1;
}

.btn-close:hover {
  color: #ffffff;
}

.modal-body {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background-color: #050507;
}

.image-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 64vh;
  width: 100%;
}

.modal-image {
  max-width: 100%;
  max-height: 64vh;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.modal-footer {
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  gap: 0.5rem;
}

.modal-nav, .modal-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Pagination */
.pagination-container {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 340px;
  width: calc(100% - 2.5rem);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.825rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s ease-out;
}

.toast.toast-success { border-left: 3px solid #10b981; }
.toast.toast-error { border-left: 3px solid var(--accent-danger); }
.toast.toast-info { border-left: 3px solid var(--accent-cyan); }

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Mobile Optimizations */
@media (max-width: 640px) {
  .main-content {
    padding: 0.85rem 0.85rem 2.5rem;
    gap: 1.25rem;
  }

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

  .card-overlay {
    opacity: 1;
    padding: 0.4rem;
  }

  .card-filename {
    display: none;
  }

  .drop-zone {
    padding: 1.15rem 1rem;
  }

  .modal-card.modal-preview {
    max-height: 98vh;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-nav, .modal-actions {
    width: 100%;
    justify-content: space-between;
  }

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