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

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-hover: #e8eaed;
  --bg-active: #d3e3fd;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border-color: #dadce0;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --folder-color: #5f6368;
  --pdf-color: #ea4335;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
  --radius: 8px;
}

body {
  font-family: 'Google Sans', 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* Top Bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: #0088cc;
  flex-shrink: 0;
}

.brand-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.search-bar {
  flex: 1;
  max-width: 720px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar input {
  width: 100%;
  height: 44px;
  padding: 0 80px 0 44px;
  border: none;
  border-radius: 22px;
  background: var(--bg-secondary);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-secondary);
  font-size: 20px;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 40px;
}

.search-refresh {
  position: absolute;
  right: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Layout */
.layout {
  display: flex;
  margin-top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  flex-shrink: 0;
  transition: width 0.25s ease, opacity 0.25s ease;
}

.sidebar.collapsed {
  width: 0;
  opacity: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-nav {
  padding: 8px 0;
}

.sidebar-section {
  padding: 0 12px;
}

.sidebar-heading {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  padding: 16px 12px 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 20px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item:hover {
  background: var(--bg-hover);
}

.sidebar-item.active {
  background: var(--bg-active);
  color: var(--accent);
}

.sidebar-item .material-icons-outlined {
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 16px;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--topbar-height);
  background: rgba(0,0,0,0.4);
  z-index: 49;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-width: 0;
}

/* Breadcrumbs */
.breadcrumb-bar {
  padding: 12px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  cursor: pointer;
}

.breadcrumb:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.breadcrumb.current {
  color: var(--text-primary);
  font-weight: 500;
  cursor: default;
}

.breadcrumb.current:hover {
  background: transparent;
}

.breadcrumb-sep {
  color: var(--text-secondary);
  font-size: 14px;
}

/* File Grid */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  padding: 16px 24px;
}

.file-grid.list-view {
  grid-template-columns: 1fr;
  gap: 0;
}

/* File Card (Grid View) */
.file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  text-align: center;
  border: 1px solid transparent;
}

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

.file-card.selected {
  background: var(--bg-active);
  border-color: var(--accent);
}

.file-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.file-icon .material-icons-outlined {
  font-size: 48px;
}

.file-icon.folder .material-icons-outlined {
  color: var(--folder-color);
}

.file-icon.pdf .material-icons-outlined {
  color: var(--pdf-color);
}

.file-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.file-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* File Row (List View) */
.file-row {
  display: grid;
  grid-template-columns: 40px 1fr 120px 140px;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.file-row:hover {
  background: var(--bg-hover);
}

.file-row.selected {
  background: var(--bg-active);
}

.file-row .file-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 0;
}

.file-row .file-icon .material-icons-outlined {
  font-size: 22px;
}

.file-row .file-name {
  font-size: 13px;
  text-align: left;
  max-height: none;
  display: block;
  -webkit-line-clamp: unset;
}

.file-row .file-size,
.file-row .file-date {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}

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

.empty-state p {
  font-size: 14px;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.spinning .material-icons-outlined {
  animation: spin 0.8s linear infinite;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  width: 90vw;
  height: 90vh;
  background: var(--bg-primary);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  min-height: 52px;
}

.modal-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

.modal-actions {
  display: flex;
  gap: 4px;
}

.modal-body {
  flex: 1;
  overflow: hidden;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* ── Mobile ── */
@media (max-width: 768px) {
  :root {
    --topbar-height: 56px;
    --sidebar-width: 280px;
  }

  .top-bar {
    padding: 0 8px;
    gap: 8px;
  }

  .brand-text {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
    opacity: 1;
    transform: translateX(-100%);
    border-right: none;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
    padding: 12px;
  }

  .file-card {
    padding: 12px 4px 8px;
  }

  .file-icon {
    width: 48px;
    height: 48px;
  }

  .file-icon .material-icons-outlined {
    font-size: 36px;
  }

  .file-name {
    font-size: 11px;
  }

  .file-row {
    grid-template-columns: 32px 1fr 60px;
    padding: 8px 12px;
    gap: 8px;
  }

  .file-row .file-date {
    display: none;
  }

  .breadcrumb-bar {
    padding: 8px 12px;
  }

  .breadcrumb {
    font-size: 12px;
    padding: 2px 6px;
  }

  .search-bar input {
    height: 40px;
    padding-right: 76px;
    font-size: 13px;
  }

  .modal-content {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}

/* ── Small phones ── */
@media (max-width: 380px) {
  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 4px;
    padding: 8px;
  }

  .file-icon {
    width: 40px;
    height: 40px;
  }

  .file-icon .material-icons-outlined {
    font-size: 30px;
  }

  .file-name {
    font-size: 10px;
  }
}

/* ── Large screens ── */
@media (min-width: 1200px) {
  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Telegram Popup */
.tg-popup {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

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

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

.tg-popup-card {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: slideUp 0.35s ease;
}

.tg-popup-header {
  background: linear-gradient(135deg, #0088cc 0%, #005f8f 100%);
  padding: 28px 24px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.tg-icon {
  width: 48px;
  height: 48px;
  color: #fff;
}

.tg-popup-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}

.tg-popup-close:hover {
  background: rgba(255,255,255,0.35);
}

.tg-popup-body {
  padding: 24px;
  text-align: center;
}

.tg-popup-body h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.tg-popup-body p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.tg-popup-btn {
  display: inline-block;
  padding: 10px 28px;
  background: #0088cc;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.2s, transform 0.1s;
}

.tg-popup-btn:hover {
  background: #006da3;
  transform: translateY(-1px);
}
