/* ============================
   Telegram Cloud Drive — Styles
   ============================ */

:root {
  --bg: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --text: #e0e0e0;
  --text-secondary: #999;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --border: #333;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================
   Screen Management
   ============================ */

.screen { display: none; }
.screen.active { display: flex; }

#login-screen {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#main-screen {
  flex-direction: column;
  min-height: 100vh;
}

/* ============================
   Login
   ============================ */

.login-card {
  background: var(--bg-secondary);
  padding: 48px 40px;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
  width: 380px;
  max-width: 90vw;
}

.logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
#login-form input:focus { border-color: var(--accent); }
#login-btn {
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
}
#login-btn:hover { background: var(--accent-hover); }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ============================
   Top Nav
   ============================ */

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.nav-left { display: flex; align-items: center; gap: 16px; }
.logo-small { font-size: 24px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
}
.breadcrumb a:hover { color: var(--text); background: var(--bg-tertiary); }
.breadcrumb .separator { color: var(--text-secondary); }

.nav-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search-box { display: flex; gap: 4px; }
.search-box input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 13px;
  width: 180px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box button {
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}

/* ============================
   Buttons
   ============================ */

.btn-primary {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--border); }

/* ============================
   Toolbar
   ============================ */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
}

.toolbar-left { display: flex; gap: 4px; }

.view-btn {
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
}
.view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.toolbar-right { font-size: 13px; color: var(--text-secondary); }

/* ============================
   File Container
   ============================ */

.content { flex: 1; overflow-y: auto; }

.file-container {
  padding: 0 24px 24px;
  display: grid;
  gap: 12px;
}
.file-container.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.file-container.list-view {
  grid-template-columns: 1fr;
  gap: 2px;
}

/* ============================
   File / Folder Cards
   ============================ */

.file-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}
.file-card:hover { border-color: var(--accent); background: var(--bg-tertiary); }

.file-card .icon {
  font-size: 40px;
  line-height: 1;
}

.file-card .name {
  font-size: 13px;
  text-align: center;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
}

.file-card .size {
  font-size: 11px;
  color: var(--text-secondary);
}

/* List view card */
.list-view .file-card {
  flex-direction: row;
  padding: 10px 16px;
  gap: 12px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
}
.list-view .file-card:last-child { border-bottom: none; }
.list-view .file-card .icon { font-size: 24px; }
.list-view .file-card .name { text-align: left; -webkit-line-clamp: 1; flex: 1; }
.list-view .file-card .size { min-width: 80px; text-align: right; }

.file-card.selected { border-color: var(--accent); background: rgba(59,130,246,0.1); }

/* ============================
   Upload Panel
   ============================ */

.panel, .dialog { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: center; }
.panel-overlay, .dialog-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }

.panel-content, .dialog-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 18px; }
.close-btn { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; }
.close-btn:hover { color: var(--text); }
.panel-body { padding: 20px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); color: var(--accent); }
.drop-zone .hint { font-size: 12px; margin-top: 8px; }

/* Upload list */
.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.upload-item .upload-name { flex: 1; font-size: 13px; }
.upload-item .upload-size { font-size: 11px; color: var(--text-secondary); }
.upload-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.upload-progress .bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}
.upload-progress .bar.complete { background: var(--success); }
.upload-progress .bar.error { background: var(--danger); }
.upload-item .upload-status { font-size: 11px; color: var(--text-secondary); min-width: 60px; text-align: right; }

/* ============================
   Dialog
   ============================ */

.dialog-content { width: 380px; padding: 24px; }
.dialog-content h3 { margin-bottom: 16px; font-size: 16px; }
.dialog-content input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
}
.dialog-content input:focus { border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================
   Context Menu
   ============================ */

.context-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 160px;
  padding: 4px 0;
}

.context-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.context-item:hover { background: var(--bg-tertiary); }
.context-item.danger { color: var(--danger); }
.context-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* ============================
   Toast
   ============================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 13px;
  z-index: 300;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================
   Status
   ============================ */

.status-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.status-msg p { margin: 4px 0; }
