/* wolken caffee — UI styles. Built from the "Personal Cloud" concept design:
   a soft, light, Apple-flavoured file grid with a floating glass toolbar. */

:root {
  --bg-color: #f5f5f7;
  --text-main: #1d1d1f;
  --text-meta: #86868b;
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.04);
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
  --card-hover-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --float-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --accent: #007aff;
  --accent-hover: #0062cc;
  --danger: #ef4444;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-color);
  font-family: var(--font-family);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.app {
  padding-bottom: 120px;
  /* Hide scrollbar */
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body.app::-webkit-scrollbar {
  display: none;
}

::selection {
  background: #bfdbfe;
  color: #1e3a8a;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---- Layout -------------------------------------------------------------- */
.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

@media (min-width: 768px) {
  .container {
    padding: 40px;
  }
}

/* ---- File grid ----------------------------------------------------------- */
.file-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
  .file-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 768px) {
  .file-grid {
    gap: 24px;
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (min-width: 1024px) {
  .file-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (min-width: 1280px) {
  .file-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}
@media (min-width: 1536px) {
  .file-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* ---- Card entrance animation --------------------------------------------- */
/* Smooth fade-and-rise used for the login card and the file-grid cards on
   first paint. The grid staggers across the first cards so they cascade in. */
@keyframes cardFadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-card,
.toolbar {
  animation: cardFadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* The floating toolbar drifts in alongside the first cards. */
.toolbar {
  animation-delay: 0.2s;
}

/* Stagger the grid: every card from the 13th on shares the longest delay,
   while the first twelve step in one after another. */
.file-card:nth-child(n + 13) {
  animation-delay: 0.48s;
}
.file-card:nth-child(1) {
  animation-delay: 0.04s;
}
.file-card:nth-child(2) {
  animation-delay: 0.08s;
}
.file-card:nth-child(3) {
  animation-delay: 0.12s;
}
.file-card:nth-child(4) {
  animation-delay: 0.16s;
}
.file-card:nth-child(5) {
  animation-delay: 0.2s;
}
.file-card:nth-child(6) {
  animation-delay: 0.24s;
}
.file-card:nth-child(7) {
  animation-delay: 0.28s;
}
.file-card:nth-child(8) {
  animation-delay: 0.32s;
}
.file-card:nth-child(9) {
  animation-delay: 0.36s;
}
.file-card:nth-child(10) {
  animation-delay: 0.4s;
}
.file-card:nth-child(11) {
  animation-delay: 0.44s;
}
.file-card:nth-child(12) {
  animation-delay: 0.48s;
}

@media (prefers-reduced-motion: reduce) {
  .file-card,
  .toolbar {
    animation: none;
  }
}

/* ---- File card ----------------------------------------------------------- */
.file-card {
  background-color: var(--card-bg);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  aspect-ratio: 3 / 4;
  position: relative;
  overflow: hidden;
  transition:
    box-shadow 0.2s cubic-bezier(0.25, 0.8, 0.25, 1),
    transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* The `display: flex` above outranks the UA `[hidden]{display:none}` rule, so
   the search filter's `card.hidden = true` would otherwise have no effect. */
.file-card[hidden] {
  display: none;
}

.file-card:hover {
  box-shadow: var(--card-hover-shadow);
}

/* Top action row */
.card-actions {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  gap: 0;
  color: rgba(156, 163, 175, 0.85);
  margin-top: -8px;
  margin-left: -8px;
  z-index: 2;
}

.card-actions .inline {
  display: flex;
}

.ca-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 8px;
  display: flex;
  align-items: center;
  transition:
    color 0.2s,
    transform 0.15s ease;
}

.ca-btn svg {
  width: 14px;
  height: 14px;
}

.ca-btn:hover {
  color: #1f2937;
  transform: scale(1.15);
}

.ca-btn.delete:hover {
  color: var(--danger);
}

.ca-btn:active {
  transform: scale(0.9);
}

/* Centered icon bubble */
.main-icon {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.icon-bubble {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
}

.icon-bubble svg {
  width: 36px;
  height: 36px;
}

.file-card:hover .icon-bubble {
  transform: scale(1.07);
}

/* Metadata */
.card-meta {
  text-align: center;
  width: 100%;
  display: block;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

.card-info {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-meta);
  letter-spacing: 0.1em;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: rgba(134, 134, 139, 0.6);
}

/* ---- Empty / search states ---------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 120px 24px;
  color: var(--text-meta);
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 14px;
}

.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-meta);
  font-size: 14px;
}

/* Drag feedback: highlight the toolbar drop target while dragging files. */
body.dragging .btn-drag {
  background-color: rgba(0, 122, 255, 0.12);
  box-shadow:
    0 0 0 2px rgba(0, 122, 255, 0.4),
    var(--float-shadow);
}

body.dragging .btn-drag svg,
body.dragging .btn-drag span {
  color: var(--accent);
}

/* ---- Floating bottom toolbar -------------------------------------------- */
.bottom-bar {
  position: fixed;
  bottom: 32px;
  left: 0;
  right: 0;
  pointer-events: none;
  display: flex;
  justify-content: center;
  z-index: 50;
  padding: 0 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  max-width: 100%;
}

.toolbar-item {
  height: 44px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 9999px;
  box-shadow: var(--float-shadow);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  transition:
    background-color 0.2s,
    box-shadow 0.2s;
  outline: none;
}

.toolbar-item:hover {
  background-color: rgba(249, 250, 251, 0.85);
}

.toolbar-item:focus-visible,
.toolbar-item:focus-within {
  box-shadow:
    0 0 0 2px #d1d5db,
    var(--float-shadow);
}

.btn-avatar {
  width: 44px;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.btn-avatar svg {
  width: 20px;
  height: 20px;
  color: #374151;
  transition: color 0.2s;
}

.btn-avatar:hover svg {
  color: #111827;
}

/* Avatar popup menu */
.avatar-wrapper {
  position: relative;
  display: flex;
}

.avatar-menu {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--card-border);
  padding: 8px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  pointer-events: none;
}

.avatar-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.avatar-menu-header {
  padding: 8px 12px 12px 12px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 4px;
  cursor: default;
}

.avatar-menu-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
}

.avatar-menu-email {
  font-size: 11px;
  color: var(--text-meta);
  margin-top: 2px;
}

.avatar-menu form {
  display: flex;
}

.avatar-menu-item {
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.avatar-menu-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.avatar-menu-item.danger {
  color: var(--danger);
}

.avatar-menu-item.danger:hover {
  background-color: #fef2f2;
}

.avatar-menu-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

/* Upload (drag & drop) button */
.btn-drag {
  padding: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* Progress fill: a translucent blue bar whose width tracks --upload-progress.
   The pill's overflow:hidden clips it to the rounded shape. On completion the
   button gets .upload-done, which fades the fill back to the normal colour. */
.btn-drag::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--upload-progress, 0%);
  background: rgba(0, 122, 255, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: width 0.2s ease;
}

.btn-drag.upload-active::before {
  opacity: 1;
}

.btn-drag.upload-done::before {
  opacity: 0;
  transition:
    width 0.2s ease,
    opacity 0.6s ease;
}

.btn-drag-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  height: 100%;
  cursor: pointer;
}

.btn-drag svg {
  width: 16px;
  height: 16px;
  color: #9ca3af;
  transition: color 0.2s;
}

.btn-drag span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-meta);
  letter-spacing: 0.025em;
  transition: color 0.2s;
  white-space: nowrap;
}

.btn-drag:hover svg {
  color: #4b5563;
}
.btn-drag:hover span {
  color: #374151;
}

.btn-noscript {
  margin-left: 8px;
}

/* Search box */
.search-box {
  padding: 0 20px;
  gap: 8px;
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: #9ca3af;
  flex-shrink: 0;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  width: 128px;
  transition: width 0.3s;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-meta);
}

.search-box input:focus {
  width: 192px;
}

@media (max-width: 600px) {
  .btn-drag span {
    display: none;
  }
  .btn-drag-label {
    padding: 0 16px;
  }
  .search-box input {
    width: 96px;
  }
  .search-box input:focus {
    width: 120px;
  }
}

/* ---- Flash messages ------------------------------------------------------ */
.flash {
  border-radius: 14px;
  padding: 12px 18px;
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}

.flash-ok {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.flash-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* ---- Button primitives (shared with the JS share modal) ------------------ */
.inline {
  display: inline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background-color 0.2s;
}

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

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--text-main);
  border-color: var(--card-border);
  box-shadow: var(--card-shadow);
}

.btn-ghost:hover {
  background: #f0f0f3;
  opacity: 1;
}

/* ---- Share modal (built in app.js) -------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  padding: 28px;
  width: 100%;
  max-width: 440px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-meta);
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-right: 24px;
  word-break: break-word;
}

.modal-text {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-loading {
  color: var(--text-meta);
  font-size: 14px;
}

.modal-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-row input {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e2e6;
  background: #fbfbfd;
  outline: none;
  min-width: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-pw {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

.modal-label {
  display: block;
  font-size: 13px;
  color: var(--text-meta);
  margin-bottom: 8px;
}
