/* S_OBLAKO — стили веб-интерфейса */

:root {
  --accent: #0369a1;
  --accent-dark: #075985;
  --accent-light: #e0f2fe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }

/* скрытые от гостей элементы (видит только редактор) */
.frow.is-hidden, .tile.is-hidden { opacity: .55; }
.tile.is-hidden .tile-img img { filter: grayscale(.75); }
.frow.is-hidden:hover, .tile.is-hidden:hover { opacity: .8; }
.hidden-badge {
  display: inline-block; margin-left: 6px;
  background: #fef3c7; color: #92400e;
  border: 1px solid #fcd34d; border-radius: 6px;
  font-size: 10px; padding: 1px 6px; vertical-align: middle;
  white-space: nowrap;
}
button { font: inherit; }

/* ---------------- Кнопки ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(100, 116, 139, .12); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger-ico { color: var(--danger); }
.btn-block { width: 100%; justify-content: center; }

/* ---------------- Вход ---------------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #38bdf8 0%, #0369a1 60%, #0c4a6e 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(2, 48, 82, .35);
  padding: 36px 32px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.login-logo {
  background: #0d0d12;
  border-radius: 14px;
  padding: 14px 14px 10px;
  margin: -6px 0 16px;
  box-shadow: inset 0 0 30px rgba(220, 38, 38, .12);
}
.login-logo img { width: 100%; height: auto; display: block; border-radius: 8px; }
.login-card h1 { margin: 8px 0 2px; font-size: 26px; letter-spacing: 1px; }
.login-sub { margin: 0 0 22px; color: var(--muted); }
.login-card label { display: block; text-align: left; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 5px;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.login-or { color: var(--muted); font-size: 12px; margin: 12px 0; }
.btn-guest { background: var(--card); color: var(--accent-dark); font-weight: 600; }
.btn-guest:hover { background: var(--accent-light); border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: wait; }

/* ---------------- Каркас приложения ---------------- */
.app { max-width: 1000px; margin: 0 auto; padding: 0 14px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand-ico { filter: drop-shadow(0 2px 3px rgba(3, 105, 161, .3)); }
.userbox { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font-size: 13px;
}
.role-chip {
  background: var(--accent-light); color: var(--accent-dark);
  border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}

/* Место */
.quota-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.quota-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.quota-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.quota-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #38bdf8, var(--accent)); transition: width .4s; }
.quota-fill.warn { background: #f59e0b; }
.quota-fill.full { background: var(--danger); }

/* Панель инструментов */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar-group { display: flex; gap: 8px; }
.view-toggle { display: flex; gap: 4px; }
.view-toggle .btn-icon { padding: 8px 10px; font-size: 15px; line-height: 1; }
.view-toggle .btn-icon.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#search {
  flex: 1; min-width: 160px;
  padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); font-size: 14px; outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* Хлебные крошки */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font-size: 14px; margin-bottom: 10px; }
.crumb {
  padding: 4px 9px; border-radius: 7px; cursor: pointer;
  color: var(--accent-dark); text-decoration: none;
}
.crumb:hover { background: var(--accent-light); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--muted); user-select: none; }

/* ---------------- Список файлов ---------------- */
.filelist { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.frow {
  display: grid;
  grid-template-columns: 34px 1fr 110px 150px auto;
  align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.frow:last-child { border-bottom: none; }
.frow:hover { background: #f8fafc; }
.frow .f-ico { font-size: 22px; text-align: center; }
.frow .f-name { overflow-wrap: anywhere; }
.frow .f-size, .frow .f-date { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.frow .f-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.frow:hover .f-actions, .frow:focus-within .f-actions { opacity: 1; }
.f-act {
  border: none; background: transparent; cursor: pointer;
  font-size: 15px; padding: 6px; border-radius: 7px; line-height: 1;
}
.f-act:hover { background: var(--border); }
.f-act.danger:hover { background: #fee2e2; }

.empty-state {
  text-align: center; color: var(--muted);
  background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 48px 20px; font-size: 15px;
}
.empty-state .big { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------------- Режим плиток («фотостена», без обрезки) ---------------- */
.filelist.filegrid {
  display: block;
  column-width: 200px;
  column-gap: 12px;
  padding: 12px;
}
.tile {
  position: relative;
  break-inside: avoid;
  margin: 0 0 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, box-shadow .15s;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tile-img {
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(45deg, #f1f5f9 25%, #e2e8f0 25%, #e2e8f0 50%, #f1f5f9 50%, #f1f5f9 75%, #e2e8f0 75%);
  background-size: 16px 16px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  margin-bottom: 7px;
}
.tile-img img {
  width: 100%; height: auto; /* свои пропорции, без обрезки */
  display: block;
}
.tile-img.fixed { aspect-ratio: 4 / 3; } /* папки и не-фото — ровные плитки */
.tile-ico { font-size: 56px; line-height: 1; }
.tile-name {
  font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-word;
}
.tile .f-actions {
  position: absolute; top: 10px; right: 8px;
  display: flex; gap: 3px;
  opacity: 0; transition: opacity .12s;
  background: rgba(255,255,255,.85);
  border-radius: 8px; padding: 1px;
}
.tile:hover .f-actions, .tile:focus-within .f-actions { opacity: 1; }

/* зум картинок в просмотрщике: клик — вписать/1:1 */
.overlay-content img { cursor: zoom-in; }
.overlay-content img.zoom-full {
  max-width: none; max-height: none;
  cursor: zoom-out;
}

@media (max-width: 640px) {
  .filelist.filegrid { column-width: 135px; column-gap: 8px; padding: 8px; }
  .tile-ico { font-size: 42px; }
  .tile .f-actions { opacity: 1; }
}

/* ---------------- Просмотр файла ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 6, 23, .92);
  display: flex; flex-direction: column;
}
.overlay-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; color: #fff; background: rgba(15, 23, 42, .7);
}
.overlay-name { overflow-wrap: anywhere; font-size: 14px; }
.overlay-actions { display: flex; gap: 8px; flex-shrink: 0; }
.overlay-actions .btn { color: #e2e8f0; border-color: rgba(148, 163, 184, .4); background: rgba(15, 23, 42, .5); }
.overlay-actions .btn:hover { background: rgba(51, 65, 85, .8); }
.overlay-content {
  flex: 1; overflow: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.overlay-content img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.overlay-content video { max-width: 100%; max-height: 100%; }
.overlay-content audio { width: min(560px, 90vw); }
.overlay-content iframe { width: 100%; height: 100%; border: none; background: #fff; }
.overlay-content pre {
  align-self: stretch; width: 100%;
  overflow: auto; margin: 0;
  background: #0f172a; color: #e2e8f0;
  padding: 18px; font-size: 13px; line-height: 1.55;
  border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.preview-card { text-align: center; color: #e2e8f0; }
.preview-card .big { font-size: 60px; display: block; margin-bottom: 14px; }

/* ---------------- Панель загрузок ---------------- */
.upload-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 40;
  width: min(340px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.upload-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; font-size: 13px; font-weight: 600;
  background: var(--accent-light); color: var(--accent-dark);
}
#upload-list { max-height: 240px; overflow: auto; }
.up-item { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.up-item:last-child { border-bottom: none; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 5px; }
.up-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.up-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up-item.done .up-fill { background: var(--ok); width: 100% !important; }
.up-item.fail .up-fill { background: var(--danger); width: 100% !important; }
.up-status { font-size: 11px; color: var(--muted); margin-top: 3px; }
.up-item.fail .up-status { color: var(--danger); }

/* ---------------- Зона перетаскивания ---------------- */
.dropzone {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 105, 161, .25);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  border: 4px dashed var(--accent);
  font-size: 20px; font-weight: 600; color: var(--accent-dark);
  pointer-events: none;
}

/* ---------------- Тост ---------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 22px; z-index: 70;
  background: #0f172a; color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px); text-align: center;
}

/* ---------------- Мобильная версия ---------------- */
@media (max-width: 640px) {
  .app { padding: 0 8px 40px; }
  .brand { font-size: 17px; }
  .frow { grid-template-columns: 30px 1fr auto auto; padding: 11px 10px; }
  .frow .f-date { display: none; }
  .frow .f-size { font-size: 12px; max-width: 78px; }
  .frow .f-actions { opacity: 1; }
  .toolbar { gap: 6px; }
  .toolbar .btn { padding: 8px 10px; }
}
