/* CSS Variables for Themes */
:root {
  /* Dark Theme (Default) */
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --background: #0F172A;
  --surface: #1E293B;
  --surface-hover: #334155;
  --text: #F8FAFC;
  --text-secondary: #94A3B8;
  --border: #334155;
  --accent: #60A5FA;
  --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --background: #F8FAFC;
  --surface: #FFFFFF;
  --surface-hover: #F1F5F9;
  --text: #0F172A;
  --text-secondary: #64748B;
  --border: #E2E8F0;
  --accent: #3B82F6;
  --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="midnight"] {
  --primary: #7C3AED;
  --primary-hover: #6D28D9;
  --background: #0F0F23;
  --surface: #1E1E3F;
  --surface-hover: #2D2D5F;
  --text: #F8FAFC;
  --text-secondary: #A78BFA;
  --border: #2D2D5F;
  --accent: #A78BFA;
  --shadow: rgba(124, 58, 237, 0.2);
}

[data-theme="forest"] {
  --primary: #10B981;
  --primary-hover: #059669;
  --background: #022C22;
  --surface: #064E3B;
  --surface-hover: #065F46;
  --text: #F8FAFC;
  --text-secondary: #6EE7B7;
  --border: #065F46;
  --accent: #34D399;
  --shadow: rgba(16, 185, 129, 0.2);
}

[data-theme="sunset"] {
  --primary: #EA580C;
  --primary-hover: #DC2626;
  --background: #431407;
  --surface: #7C2D12;
  --surface-hover: #9A3412;
  --text: #F8FAFC;
  --text-secondary: #FDBA74;
  --border: #9A3412;
  --accent: #FB923C;
  --shadow: rgba(234, 88, 12, 0.2);
}

[data-theme="ocean"] {
  --primary: #0891B2;
  --primary-hover: #0E7490;
  --background: #083344;
  --surface: #155E75;
  --surface-hover: #0E7490;
  --text: #F8FAFC;
  --text-secondary: #67E8F9;
  --border: #0E7490;
  --accent: #22D3EE;
  --shadow: rgba(8, 145, 178, 0.2);
}

[data-theme="rose"] {
  --primary: #E11D48;
  --primary-hover: #BE123C;
  --background: #4C0519;
  --surface: #881337;
  --surface-hover: #9F1239;
  --text: #F8FAFC;
  --text-secondary: #FDA4AF;
  --border: #9F1239;
  --accent: #FB7185;
  --shadow: rgba(225, 29, 72, 0.2);
}

[data-theme="amber"] {
  --primary: #D97706;
  --primary-hover: #B45309;
  --background: #451A03;
  --surface: #78350F;
  --surface-hover: #92400E;
  --text: #F8FAFC;
  --text-secondary: #FCD34D;
  --border: #92400E;
  --accent: #FBBF24;
  --shadow: rgba(217, 119, 6, 0.2);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header Styles */
.header {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background-color: rgba(var(--surface), 0.95);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  transition: all 0.3s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
}

.title-section h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
}

.file-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.search-container {
  flex: 1;
  max-width: 400px;
  margin: 0 32px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 8px 16px 8px 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary), 0.1);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-btn, .view-btn, .upload-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 14px;
}

.control-btn:hover, .view-btn:hover, .upload-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.05);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  border-radius: 0;
  border: none;
}

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

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

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

/* Dropdown Styles */
.dropdown {
  position: relative;
}

.dropdown-content {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 50;
}

.dropdown:hover .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dropdown-item {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-item.active {
  background: var(--primary);
  color: white;
}

.theme-dropdown {
  min-width: 240px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px;
}

.theme-option {
  padding: 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-option:hover {
  transform: scale(1.05);
}

.theme-option.active {
  border-color: var(--accent);
}

/* Main Container */
.main-container {
  display: flex;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-content {
  padding: 24px;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  background: var(--surface-hover);
  transition: all 0.3s ease;
  margin-bottom: 24px;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--surface);
}

.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary);
  background-opacity: 0.1;
}

.upload-icon, .loading-icon {
  font-size: 32px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.upload-text, .loading-text {
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-size: 14px;
}

.browse-btn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.browse-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

/* Folder List */
.folder-list {
  min-height: 200px;
}

.folder-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  user-select: none;
  border: 1px solid transparent;
}

.folder-list-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  transform: translateX(4px);
}

.folder-list-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.folder-list-icon {
  font-size: 18px;
  color: var(--text-secondary);
  width: 24px;
  text-align: center;
}

.folder-list-item.active .folder-list-icon {
  color: white;
}

.folder-list-info {
  flex: 1;
  min-width: 0;
}

.folder-list-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.folder-list-count {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.8;
}

.folder-list-item.active .folder-list-count {
  color: rgba(255, 255, 255, 0.8);
}

/* Navigation Bar */
.navigation-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}

.back-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 14px;
}

.back-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.05);
}

.current-path {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-path::before {
  content: '';
  width: 4px;
  height: 4px;
  background: var(--primary);
  border-radius: 50%;
}

.empty-state, .content-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-subtitle {
  font-size: 14px;
  margin: 0;
}


/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  background: var(--background);
}

.media-container {
  padding: 0 24px 24px 24px;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-secondary);
}

/* Media Grid */
.media-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

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

.media-grid.spacious {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.media-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  group: hover;
}

.media-item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 20px 40px var(--shadow);
  border-color: var(--primary);
}

.media-preview {
  position: relative;
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: var(--surface-hover);
}

.media-grid.compact .media-preview {
  height: 120px;
}

.media-grid.spacious .media-preview {
  height: 200px;
}

.media-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.3s ease;
}

.media-item:hover .media-image {
  transform: scale(1.1);
}

.media-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 32px;
}

.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  opacity: 0;
  transition: all 0.3s ease;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}

.media-item:hover .media-overlay {
  opacity: 1;
}

.media-info {
  padding: 16px;
}

.media-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.media-type {
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

/* Media List */
.media-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.media-list-item:hover {
  background: var(--surface-hover);
  transform: translateX(4px);
}

.media-list-preview {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-hover);
  flex-shrink: 0;
}

.media-list-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-list-info {
  flex: 1;
  min-width: 0;
}

.media-list-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-list-details {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.media-list-detail {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Fullscreen Viewer */
.fullscreen-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  flex-direction: column;
}

.fullscreen-viewer.active {
  display: flex;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.viewer-info {
  color: white;
}

.viewer-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-counter {
  font-size: 14px;
  opacity: 0.7;
  margin: 0;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.zoom-level {
  color: white;
  font-size: 14px;
  font-weight: 500;
  min-width: 50px;
  text-align: center;
}

.viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 24px;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.nav-prev {
  left: 24px;
}

.nav-next {
  right: 24px;
}

.image-container {
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
  transform-origin: center;
}

.viewer-footer {
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.image-info {
  display: flex;
  justify-content: center;
  gap: 32px;
  color: white;
  font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
  }
  
  .search-container {
    margin: 0 16px;
    max-width: 200px;
  }
  
  .header-controls {
    gap: 4px;
  }
  
  .sidebar {
    width: 280px;
  }
  
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  
  .viewer-header {
    padding: 12px 16px;
  }
  
  .viewer-controls {
    gap: 4px;
  }
  
  .viewer-btn {
    width: 36px;
    height: 36px;
  }
  
  .nav-btn {
    width: 40px;
    height: 40px;
  }
  
  .image-info {
    gap: 16px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .main-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.media-item {
  animation: fadeIn 0.3s ease forwards;
}

.folder-item {
  animation: slideIn 0.2s ease forwards;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}