/* ── style.css ──────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f5f3ef;
  --surface:     #ffffff;
  --border:      #e0ddd6;
  --text:        #1a1917;
  --text-muted:  #6b6860;
  --accent:      #1a1917;
  --audio-bg:    #eef6f1;
  --audio-tag:   #1e6b45;
  --video-bg:    #edf2fb;
  --video-tag:   #1a4fa0;
  --pdf-bg:      #fdf0eb;
  --pdf-tag:     #a03a1a;
  --radius:      10px;
  --font:        'DM Sans', sans-serif;
  --font-mono:   'DM Mono', monospace;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ── Login page ─────────────────────────────────────────────────────────────── */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-wrap { width: 100%; max-width: 380px; padding: 1.5rem; }
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem 2rem;
  text-align: center;
}
.login-icon { font-size: 2rem; margin-bottom: 1rem; }
.login-box h1 { font-size: 1.4rem; font-weight: 600; margin-bottom: .4rem; }
.login-sub  { font-size: .875rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.login-error {
  background: #fdf0eb; color: var(--pdf-tag);
  border: 1px solid #f5c4a8; border-radius: 7px;
  font-size: .8rem; padding: .6rem .9rem; margin-bottom: 1rem;
}
.field { text-align: left; margin-bottom: 1rem; }
.field label { display: block; font-size: .8rem; font-weight: 500; margin-bottom: .4rem; color: var(--text-muted); }
.field input {
  width: 100%; padding: .65rem .9rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: .9rem;
  background: var(--bg); color: var(--text);
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.2rem; background: var(--accent); color: #fff;
  border: none; border-radius: 8px; font-family: var(--font);
  font-size: .875rem; font-weight: 500; cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-primary.full  { width: 100%; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 4px;
  padding: .45rem .9rem;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: .8rem; font-weight: 500; color: var(--text-muted);
  background: transparent; cursor: pointer; transition: background .15s;
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

/* ── Top bar ────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 2rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand { font-weight: 600; font-size: 1rem; letter-spacing: -.02em; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.role-badge {
  font-size: .75rem; font-weight: 500; padding: .3rem .75rem;
  border-radius: 99px; border: 1px solid var(--border);
}
.role-badge.admin  { background: #1a1917; color: #fff; border-color: #1a1917; }
.role-badge.viewer { background: var(--bg); color: var(--text-muted); }

/* ── Container ──────────────────────────────────────────────────────────────── */
.container { max-width: 1140px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Flash message ──────────────────────────────────────────────────────────── */
.flash {
  background: #eef6f1; color: var(--audio-tag);
  border: 1px solid #b8dfc9; border-radius: 8px;
  padding: .75rem 1rem; font-size: .875rem; margin-bottom: 1.5rem;
}

/* ── Upload panel ───────────────────────────────────────────────────────────── */
.upload-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
}
.upload-panel h2 { font-size: .9rem; font-weight: 600; margin-bottom: .9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.upload-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

.file-pick {
  position: relative; display: inline-flex; align-items: center;
  cursor: pointer;
}
.file-pick input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%;
}
.file-pick span {
  padding: .6rem 1.1rem; border: 1px dashed var(--border);
  border-radius: 8px; font-size: .875rem; color: var(--text-muted);
  background: var(--bg); white-space: nowrap;
}
.file-pick:hover span { border-color: var(--accent); color: var(--text); }

.desc-input {
  flex: 1; min-width: 180px; padding: .6rem .9rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: .875rem;
  background: var(--bg); color: var(--text);
}
.desc-input:focus { outline: none; border-color: var(--accent); }

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-bottom: 1.5rem;
}
.search-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.search-input {
  padding: .5rem .9rem; border: 1px solid var(--border);
  border-radius: 8px; font-family: var(--font); font-size: .875rem;
  background: var(--surface); color: var(--text); width: 220px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.filter-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: .4rem .85rem; border: 1px solid var(--border);
  border-radius: 99px; font-size: .8rem; font-weight: 500;
  color: var(--text-muted); transition: all .15s;
}
.filter-btn:hover  { background: var(--surface); color: var(--text); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-btn .count { font-size: .7rem; opacity: .7; }

/* ── Grid ───────────────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 860px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.07); }

.card.audio { border-top: 3px solid #3cbe80; }
.card.video { border-top: 3px solid #4a8cf7; }
.card.pdf   { border-top: 3px solid #f47c42; }

.card-head {
  display: flex; align-items: center; gap: .4rem;
  padding: .65rem .9rem .3rem;
}
.serial {
  font-family: var(--font-mono); font-size: .7rem;
  color: var(--text-muted); margin-right: auto;
}
.type-tag {
  font-size: .65rem; font-weight: 600; letter-spacing: .06em;
  padding: .2rem .55rem; border-radius: 99px;
}
.type-tag.audio { background: var(--audio-bg); color: var(--audio-tag); }
.type-tag.video { background: var(--video-bg); color: var(--video-tag); }
.type-tag.pdf   { background: var(--pdf-bg);   color: var(--pdf-tag); }

.delete-btn {
  font-size: .75rem; color: #ccc; cursor: pointer; line-height: 1;
  padding: .1rem .3rem; border-radius: 4px;
}
.delete-btn:hover { background: #fdf0eb; color: var(--pdf-tag); }

.card-icon {
  font-size: 2rem; text-align: center;
  padding: .75rem 1rem .5rem;
}

.card-body { padding: 0 1rem .75rem; flex: 1; }
.card-name {
  font-size: .875rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: .3rem;
}
.card-desc {
  font-size: .8rem; color: var(--text-muted);
  line-height: 1.45; margin-bottom: .4rem;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  font-family: var(--font-mono); font-size: .72rem; color: var(--text-muted);
}

.card-actions {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .5rem;
}
.player { width: 100%; height: 36px; }
video.player { height: 160px; object-fit: cover; border-radius: 6px; }

.btn-view, .btn-download {
  display: flex; align-items: center; justify-content: center;
  padding: .5rem; border-radius: 7px;
  font-size: .8rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); transition: background .15s;
}
.btn-view     { background: var(--bg); color: var(--text-muted); }
.btn-view:hover { background: var(--border); }
.btn-download { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-download:hover { opacity: .85; }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty {
  text-align: center; color: var(--text-muted);
  font-size: .9rem; padding: 3rem 0;
}
