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

:root {
  --primary-color: #0082c9;
  --primary-hover: #006fa8;
  --secondary-color: #333;
  --background-color: #1a1a2e;
  --surface-color: #16213e;
  --surface-hover: #1f2b4a;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #6c6c6c;
  --border-color: #2a2a3e;
  --success-color: #4caf50;
  --error-color: #f44336;
  --warning-color: #ff9800;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --transition-speed: 0.2s;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  overflow: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--surface-color) 0%, #0f172a 100%);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow-color);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  margin: 0 auto;
}

.header h1 {
  font-size: 1.4rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 20px;
}

.header h1 i {
  font-size: 1.2rem;
}

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

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  background: var(--surface-hover);
  border-radius: 25px;
  padding: 8px 15px;
  border: 1px solid var(--border-color);
  transition: all var(--transition-speed);
}

.search-box:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 130, 201, 0.3);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  width: 200px;
  outline: none;
  transition: width var(--transition-speed);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  width: 300px;
}

.search-box button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px;
  transition: color var(--transition-speed);
}

.search-box button:hover {
  color: var(--primary-color);
}

/* View Mode Toggle */
.view-mode-toggle {
  display: flex;
  background: var(--surface-hover);
  border-radius: 25px;
  padding: 5px;
  border: 1px solid var(--border-color);
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 20px;
  transition: all var(--transition-speed);
}

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

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

/* Header Buttons */
.header-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed);
}

.header-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  transform: scale(1.1);
}

.header-btn:active {
  transform: scale(0.95);
}

/* Breadcrumb */
.breadcrumb {
  background: var(--surface-color);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  z-index: 90;
}

.breadcrumb-content {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  background: var(--surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-speed);
}

.breadcrumb-item:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.breadcrumb-item i {
  margin-right: 8px;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.breadcrumb-list .breadcrumb-item {
  padding: 6px 12px;
}

.breadcrumb-list .breadcrumb-item:after {
  content: '/';
  color: var(--text-muted);
  margin-left: 12px;
  font-size: 0.9rem;
}

.breadcrumb-list .breadcrumb-item:last-child:after {
  content: '';
}

/* Main Content */
.main-content {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: var(--background-color);
  position: relative;
}

/* Loading Spinner */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  color: var(--text-secondary);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  text-align: center;
  color: var(--error-color);
  padding: 20px;
  background: var(--surface-color);
  border-radius: 10px;
  border: 1px solid var(--error-color);
  max-width: 400px;
}

.error-message i {
  font-size: 2rem;
}

.error-message p {
  font-size: 1.1rem;
}

.retry-btn {
  background: var(--error-color);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition-speed);
}

.retry-btn:hover {
  background: #d32f2f;
  transform: scale(1.05);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
  padding: 10px 0;
}

.gallery-list {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.gallery-list.active {
  display: flex;
}

.gallery-grid.hidden {
  display: none;
}

/* Gallery Item */
.gallery-item {
  position: relative;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-speed);
  aspect-ratio: 1;
}

.gallery-item:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 10px 30px var(--shadow-color);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.1);
}

.gallery-item-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: 15px 10px 10px;
  color: white;
  opacity: 0;
  transition: opacity var(--transition-speed);
}

.gallery-item:hover .gallery-item-info {
  opacity: 1;
}

.gallery-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.gallery-item-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.gallery-item-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.2rem;
  color: var(--text-muted);
}

/* List View Item */
.gallery-list-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 15px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.gallery-list-item:hover {
  background: var(--surface-hover);
  border-color: var(--primary-color);
  transform: translateX(5px);
}

.gallery-list-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

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

.gallery-list-item-name {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-list-item-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gallery-list-item-type {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.gallery-list-item-icon {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Folder Item */
.folder-item {
  background: var(--surface-hover);
  border: 1px solid var(--primary-color);
}

.folder-item .gallery-item-icon,
.folder-item .gallery-list-item-icon {
  color: var(--primary-color);
}

/* Empty State */
.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state i {
  font-size: 3rem;
  color: var(--border-color);
}

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

.empty-state p {
  font-size: 0.95rem;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-speed);
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  background: var(--surface-color);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform var(--transition-speed);
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  z-index: 10;
  transition: all var(--transition-speed);
}

.modal-close:hover {
  color: var(--error-color);
  transform: scale(1.2);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(22, 33, 62, 0.9);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 15px 20px;
  border-radius: 5px;
  transition: all var(--transition-speed);
  z-index: 10;
}

.modal-nav:hover {
  background: var(--surface-hover);
  color: var(--primary-color);
}

.modal-prev {
  left: 15px;
}

.modal-next {
  right: 15px;
}

.modal-action {
  position: absolute;
  bottom: 15px;
  background: var(--surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed);
  z-index: 10;
}

.modal-action:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.download-btn {
  right: 100px;
}

.fullscreen-btn {
  right: 45px;
}

.preview-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #000;
}

.preview-image,
.preview-video,
.preview-media {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  cursor: zoom-in;
}

.preview-video {
  width: 100%;
  background: #000;
}

.preview-info {
  padding: 15px 20px;
  background: var(--surface-color);
  border-top: 1px solid var(--border-color);
}

.preview-info h3 {
  font-size: 1rem;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Slideshow Overlay */
.slideshow-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-speed);
}

.slideshow-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.slideshow-overlay.active {
  opacity: 1;
  visibility: visible;
}

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

.slideshow-image,
.slideshow-video,
.slideshow-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.slideshow-video {
  width: 100%;
  background: #000;
}

.slideshow-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 33, 62, 0.9);
  padding: 10px 20px;
  border-radius: 20px;
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
}

.slideshow-control {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 130, 201, 0.9);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all var(--transition-speed);
}

.slideshow-control:hover {
  background: var(--primary-hover);
  transform: translateX(-50%) scale(1.1);
}

.slideshow-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(22, 33, 62, 0.7);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 20px 25px;
  border-radius: 5px;
  transition: all var(--transition-speed);
}

.slideshow-nav:hover {
  background: rgba(22, 33, 62, 0.9);
  color: var(--primary-color);
}

.slideshow-prev {
  left: 20px;
}

.slideshow-next {
  right: 20px;
}

.slideshow-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  transition: all var(--transition-speed);
}

.slideshow-close:hover {
  color: var(--error-color);
  transform: scale(1.2);
}

/* Fullscreen Viewer */
.fullscreen-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-speed);
}

.fullscreen-viewer.hidden {
  opacity: 0;
  visibility: hidden;
}

.fullscreen-viewer.active {
  opacity: 1;
  visibility: visible;
}

.fullscreen-image,
.fullscreen-video,
.fullscreen-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.fullscreen-video {
  width: 100%;
  background: #000;
}

.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(22, 33, 62, 0.8);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 10px 15px;
  border-radius: 5px;
  transition: all var(--transition-speed);
}

.fullscreen-close:hover {
  background: var(--surface-hover);
  color: var(--primary-color);
}

/* Footer */
.footer {
  background: var(--surface-color);
  padding: 10px 20px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer i {
  margin-right: 8px;
  color: var(--primary-color);
}

/* Hidden utility class */
.hidden {
  display: none !important;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Touch device styles */
@media (hover: none) {
  .gallery-item:hover,
  .gallery-list-item:hover,
  .header-btn:hover,
  .modal-nav:hover,
  .modal-action:hover {
    transform: none;
  }
  
  .gallery-item:hover .gallery-item-info {
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  
  .header {
    padding: 10px 15px;
  }
  
  .header h1 {
    font-size: 1.2rem;
  }
  
  .search-box input {
    width: 150px;
  }
  
  .search-box input:focus {
    width: 200px;
  }
  
  .modal-action {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .download-btn {
    right: 80px;
  }
  
  .fullscreen-btn {
    right: 35px;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }
  
  .header-controls {
    gap: 10px;
  }
  
  .header-btn {
    width: 35px;
    height: 35px;
  }
  
  .search-box {
    display: none;
  }
}
