/* ===========================
   DriveBox — Global Styles
   Neo-Brutalism + Blue/White/Yellow
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
  --blue: #1d4ed8;
  --navy: #1e3a8a;
  --sky: #3b82f6;
  --blue-light: #dbeafe;
  --yellow: #fbbf24;
  --gold: #f59e0b;
  --amber-light: #fef3c7;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-900: #0f172a;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--gray-900);
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   GRID BACKGROUND PATTERN
   =========================== */
.bg-grid-pattern {
  background-image:
    linear-gradient(rgba(30, 58, 138, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 58, 138, 0.08) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ===========================
   SKELETON LOADING
   =========================== */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

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

/* ===========================
   NAV ITEMS
   =========================== */
.nav-item.active {
  background: var(--blue-light);
  color: var(--blue);
  box-shadow: 2px 2px 0px 0px var(--navy);
  border: 2px solid var(--navy);
}

.nav-item.active svg {
  color: var(--blue);
}

/* ===========================
   FILE CARDS — GRID VIEW
   =========================== */
.file-card {
  background: white;
  border: 3px solid var(--navy);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  box-shadow: 3px 3px 0 var(--navy);
  overflow: hidden;
}

.file-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.03) 0%, transparent 60%);
  pointer-events: none;
}

.file-card:hover {
  transform: translate(-2px, -3px);
  box-shadow: 5px 5px 0 var(--navy);
}

.file-card:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--navy);
}

.file-card.selected {
  background: var(--blue-light);
  border-color: var(--blue);
  box-shadow: 3px 3px 0 var(--blue);
}

.file-card .file-icon {
  font-size: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  margin-bottom: 8px;
}

.file-card .file-thumbnail {
  width: 100%;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--navy);
  margin-bottom: 8px;
}

.file-card .file-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.file-card .file-meta {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 3px;
  font-weight: 500;
}

.file-card .file-star {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.file-card:hover .file-star {
  opacity: 1;
}

.file-card .file-star.starred {
  opacity: 1;
}

/* Type badge */
.file-card .type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1.5px solid;
  margin-top: 3px;
}

/* ===========================
   FILE CARDS — LIST VIEW
   =========================== */
#file-container.list-mode {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#file-container.list-mode .file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
}

#file-container.list-mode .file-card .file-icon {
  font-size: 1.5rem;
  height: auto;
  width: 32px;
  flex-shrink: 0;
  margin-bottom: 0;
}

#file-container.list-mode .file-card .file-thumbnail {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-bottom: 0;
}

#file-container.list-mode .file-card .file-info {
  flex: 1;
  min-width: 0;
}

#file-container.list-mode .file-card .file-name {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#file-container.list-mode .file-card .file-meta {
  font-size: 0.75rem;
  margin-top: 1px;
}

#file-container.list-mode .file-card .file-size-col {
  text-align: right;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
  flex-shrink: 0;
  min-width: 70px;
}

#file-container.list-mode .file-card .file-date-col {
  text-align: right;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 100px;
  display: none;
}

@media (min-width: 640px) {
  #file-container.list-mode .file-card .file-date-col {
    display: block;
  }
}

/* ===========================
   TOAST NOTIFICATIONS
   =========================== */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 3px solid var(--navy);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
  box-shadow: 4px 4px 0 var(--navy);
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: all;
  min-width: 240px;
  max-width: 340px;
}

.toast.success { background: #dcfce7; border-color: #166534; box-shadow: 4px 4px 0 #166534; color: #14532d; }
.toast.error { background: #fee2e2; border-color: #991b1b; box-shadow: 4px 4px 0 #991b1b; color: #7f1d1d; }
.toast.info { background: var(--blue-light); border-color: var(--navy); }
.toast.warning { background: var(--amber-light); border-color: var(--gold); box-shadow: 4px 4px 0 var(--gold); color: #78350f; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); height: 0; padding: 0; margin: 0; }
}

.toast.removing {
  animation: toast-out 0.25s ease-in forwards;
}

/* ===========================
   CONTEXT MENU
   =========================== */
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.context-menu-item:hover {
  background: var(--blue-light);
}

.context-menu-item.danger {
  color: #dc2626;
}

.context-menu-item.danger:hover {
  background: #fee2e2;
}

.context-menu-item .ctx-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.context-menu-separator {
  height: 0;
  border-top: 2px solid var(--gray-100);
  margin: 4px 0;
}

/* ===========================
   VIEWER
   =========================== */
#viewer-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 4px solid var(--navy);
  border-radius: 8px;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.5);
}

#viewer-content video,
#viewer-content audio {
  max-width: 100%;
  border-radius: 8px;
  border: 4px solid var(--navy);
}

#viewer-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.viewer-text-content {
  background: #1e293b;
  color: #e2e8f0;
  padding: 24px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  max-width: 800px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  border: 4px solid var(--navy);
}

.viewer-unsupported {
  text-align: center;
  color: #94a3b8;
}

.viewer-unsupported .icon {
  font-size: 5rem;
  display: block;
  margin-bottom: 16px;
}

/* ===========================
   SEARCH DROPDOWN
   =========================== */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--gray-100);
}

.search-result-item:hover {
  background: var(--blue-light);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item .result-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.search-result-item .result-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item .result-path {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* ===========================
   FOLDER CARDS SPECIAL
   =========================== */
.file-card.is-folder {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.file-card.is-folder:hover {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

/* ===========================
   ANIMATIONS
   =========================== */
@keyframes bounce-gentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.animate-bounce-gentle {
  animation: bounce-gentle 2s ease-in-out infinite;
}

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

.file-card {
  animation: fade-in 0.25s ease-out both;
}

/* Stagger animation for file cards */
.file-card:nth-child(1) { animation-delay: 0ms; }
.file-card:nth-child(2) { animation-delay: 30ms; }
.file-card:nth-child(3) { animation-delay: 60ms; }
.file-card:nth-child(4) { animation-delay: 90ms; }
.file-card:nth-child(5) { animation-delay: 120ms; }
.file-card:nth-child(6) { animation-delay: 150ms; }
.file-card:nth-child(7) { animation-delay: 180ms; }
.file-card:nth-child(8) { animation-delay: 210ms; }
.file-card:nth-child(9) { animation-delay: 240ms; }
.file-card:nth-child(10) { animation-delay: 270ms; }
.file-card:nth-child(n+11) { animation-delay: 300ms; }

/* ===========================
   DRAG AND DROP
   =========================== */
.drop-zone-active {
  background: var(--blue-light) !important;
  border: 4px dashed var(--blue) !important;
  box-shadow: inset 0 0 30px rgba(29, 78, 216, 0.15) !important;
}

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===========================
   MOBILE TWEAKS
   =========================== */
@media (max-width: 640px) {
  #file-container {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
  }
  
  .file-card {
    padding: 8px;
  }
  
  .file-card .file-icon {
    font-size: 2rem;
    height: 44px;
  }
}

@media (max-width: 380px) {
  #file-container {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ===========================
   PWA INSTALL PROMPT
   =========================== */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: white;
  border-top: 4px solid var(--navy);
  box-shadow: 0 -4px 0 var(--navy);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slide-up 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
