/* Современный дизайн - File Storage */

:root {
  --bg-primary: #0f0f12;
  --bg-secondary: #18181c;
  --bg-card: #1e1e24;
  --accent: #00d4aa;
  --accent-hover: #00f5c4;
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --border: #2a2a32;
  --error: #ff6b6b;
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--accent);
}

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

/* Main */
.main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

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

/* Auth */
.auth-card {
  max-width: 400px;
  margin: 4rem auto;
  padding: 2.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
}

.auth-card input {
  width: 100%;
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
}

.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-switch {
  margin-top: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}

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

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

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

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-danger:hover {
  background: var(--error);
  color: white;
}

/* Files */
.files-section h1 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

/* Search bar */
.files-search-bar {
  margin-bottom: 1rem;
  position: relative;
}

.files-search-bar::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a0a0b0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") center/contain no-repeat;
}

.files-search-bar input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
}

.files-search-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Toolbar */
.files-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar-btn {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  background: white;
  color: #111;
  transition: background 0.2s;
}

.toolbar-btn:hover {
  background: #e0e0e0;
}

.toolbar-btn-dark {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.toolbar-btn-dark:hover {
  background: #25252d;
}

.create-folder-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.create-folder-form input {
  flex: 1;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
}

/* Page drop overlay */
.page-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 212, 170, 0.08);
  border: 3px dashed var(--accent);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.page-drop-overlay span {
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: 600;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Breadcrumb */
.files-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.breadcrumb-link {
  color: var(--accent);
  cursor: pointer;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--text-secondary);
}

.breadcrumb-current {
  color: var(--text-primary);
}

/* Grid tiles (как на картинке 2) */
.files-grid-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 1.25rem;
  max-width: 100%;
}

.grid-tile {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 120px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.grid-tile:hover {
  background: #25252d;
}

.grid-tile-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.folder-icon {
  background: url("/static/icons/folder.png") center/contain no-repeat;
}

.file-icon {
  background: url("/static/icons/file.png") center/contain no-repeat;
}


.grid-tile-label {
  font-size: 0.85rem;
  color: var(--text-primary);
  text-align: center;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

/* Кнопка три точки */
.tile-menu-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  line-height: 1;
  padding: 0;
}

.grid-tile:hover .tile-menu-btn {
  opacity: 1;
}

.tile-menu-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

/* Выпадающее меню */
.tile-menu {
  position: absolute;
  top: calc(100% - 8px);
  right: -90px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-direction: column;
  min-width: 120px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 100;
  overflow: hidden;
}

.tile-menu-item {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  display: block;
  font-family: inherit;
  transition: background 0.15s;
}

.tile-menu-item:hover {
  background: rgba(255,255,255,0.08);
}

.tile-menu-delete {
  color: var(--error);
}

.tile-menu-delete:hover {
  background: rgba(255,107,107,0.15);
}

.empty-state {
  color: var(--text-secondary);
  text-align: center;
  padding: 3rem;
}

.empty-state a {
  color: var(--accent);
}

/* Upload (legacy) */

/* Footer */
.footer {
  padding: 1rem 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateY(120%);
  transition: transform 0.3s;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
}

.toast.error {
  border-color: var(--error);
}

/* Responsive */
@media (max-width: 640px) {
  .header {
    flex-direction: column;
    gap: 1rem;
  }

  .main {
    padding: 1rem;
  }

  .auth-card {
    margin: 2rem auto;
    padding: 1.5rem;
  }
}
