@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root{
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1b1f24;
  --text-muted: #6b7280;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20,20,30,.06), 0 8px 24px rgba(20,20,30,.05);
  --tap: 44px; /* alvo mínimo de toque */
}

body.theme-azul{
  --accent: #2f6fed;
  --accent-dark: #1f4fc4;
  --accent-tint: #e9f0ff;
  --accent-tint-2: #d7e5ff;
}
body.theme-verde{
  --accent: #1f9d6b;
  --accent-dark: #15794f;
  --accent-tint: #e6f7f0;
  --accent-tint-2: #cdefe0;
}
body.theme-rosa{
  --accent: #e26f95;
  --accent-dark: #c9527a;
  --accent-tint: #fdeef3;
  --accent-tint-2: #fbdbe6;
}

/* ===== Base (mobile-first) ===== */
*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
h1,h2,h3,.brand{ font-family:'Space Grotesk', 'Inter', sans-serif; }
img, video{ max-width:100%; }

a{ color: var(--accent); text-decoration:none; }

/* ---------- Topbar ---------- */
.topbar{
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top:0; z-index:10;
}
.brand{
  display:flex; align-items:center; gap:8px;
  font-weight:700; font-size:1.05rem; color:var(--text);
}
.brand .mark{
  width:30px; height:30px; border-radius:8px; flex-shrink:0;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display:flex; align-items:center; justify-content:center;
  color:white; font-size:16px;
}
.topbar-right{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  width:100%;
}

/* ---------- Buttons & pills ---------- */
.pill{
  font-size:.76rem; padding:5px 10px; border-radius:999px;
  background: var(--accent-tint); color: var(--accent-dark); font-weight:600;
  white-space:nowrap;
}
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding: 10px 16px; border-radius: var(--radius); border:none;
  background: var(--accent); color:#fff; font-weight:600; font-size:.88rem;
  cursor:pointer; transition: background .15s ease, transform .05s ease;
  min-height: var(--tap);
  touch-action: manipulation;
}
.btn:hover{ background: var(--accent-dark); }
.btn:active{ transform: scale(.98); }
.btn.secondary{
  background: var(--surface); color: var(--text); border:1px solid var(--border);
}
.btn.secondary:hover{ background: var(--bg); }
.btn.danger{ background:#e5484d; }
.btn.danger:hover{ background:#c73a3e; }
.btn.small{ padding:8px 12px; font-size:.8rem; min-height:38px; }

/* ---------- Layout ---------- */
.container{ max-width: 980px; margin: 0 auto; padding: 18px 14px 48px; }

.card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad{ padding: 18px; }

/* ---------- Upload zone ---------- */
.upload-zone{
  border: 2px dashed var(--accent-tint-2);
  background: var(--accent-tint);
  border-radius: var(--radius);
  padding: 20px 16px; text-align:center; margin-bottom: 20px;
}
.upload-zone p{ margin:6px 0 14px; color: var(--text-muted); font-size:.87rem; }
.upload-zone.dragover{ background: var(--accent-tint-2); border-color: var(--accent); }
.upload-zone input[type="file"]{
  font-size:.82rem; width:100%; max-width:340px;
}

/* ---------- Tables ---------- */
.table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
table{ width:100%; min-width: 480px; border-collapse: collapse; }
th, td{ text-align:left; padding: 12px 10px; font-size:.88rem; }
thead th{ color: var(--text-muted); font-weight:600; font-size:.74rem; text-transform:uppercase; letter-spacing:.04em; border-bottom:1px solid var(--border); white-space:nowrap; }
tbody tr{ border-bottom:1px solid var(--border); }
tbody tr:last-child{ border-bottom:none; }
tbody tr:hover{ background: var(--bg); }
.file-name{ display:flex; align-items:center; gap:10px; font-weight:500; }
.file-icon{
  width:30px; height:30px; border-radius:7px; background: var(--accent-tint);
  color: var(--accent-dark); display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; flex-shrink:0;
}
.row-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.empty-state{ text-align:center; padding: 32px 10px; color: var(--text-muted); font-size:.9rem; }

/* ---------- Login ---------- */
.login-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background: linear-gradient(160deg, var(--accent-tint), var(--bg) 60%);
  padding:16px;
}
.login-card{ width:100%; max-width:380px; }
.login-card h1{ font-size:1.3rem; margin:0 0 4px; }
.login-card p.sub{ color: var(--text-muted); margin:0 0 20px; font-size:.88rem; }
.field{ margin-bottom: 14px; }
.field label{ display:block; font-size:.82rem; font-weight:600; margin-bottom:6px; color: var(--text); }
.field input, .field select{
  width:100%; padding:12px; border-radius:8px; border:1px solid var(--border);
  font-size:1rem; font-family:inherit; background:#fff;
  min-height: var(--tap);
}
.field input:focus, .field select:focus{ outline:2px solid var(--accent-tint-2); border-color: var(--accent); }
.alert{
  padding:10px 14px; border-radius:8px; font-size:.85rem; margin-bottom:16px;
}
.alert.error{ background:#fdecec; color:#b3261e; }
.alert.success{ background: var(--accent-tint); color: var(--accent-dark); }

/* ---------- Theme switch ---------- */
.theme-switch{ display:flex; gap:10px; }
.theme-dot-form{ display:inline-block; }
.theme-dot{
  width:28px; height:28px; border-radius:50%; border:2px solid transparent;
  cursor:pointer; display:block; padding:0;
  touch-action: manipulation;
}
.theme-dot.active{ border-color: var(--text); }
.theme-dot.azul{ background:#2f6fed; }
.theme-dot.verde{ background:#1f9d6b; }
.theme-dot.rosa{ background:#e26f95; }

/* ---------- Section headers ---------- */
.section-title{
  display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px;
  margin-bottom:14px;
}
.section-title h2{ font-size:1rem; margin:0; }

/* ---------- Stats ---------- */
.stat-grid{ display:grid; grid-template-columns: 1fr; gap:12px; margin-bottom:22px; }
.stat-card{ padding:16px; }
.stat-card .num{ font-family:'Space Grotesk'; font-size:1.5rem; font-weight:700; }
.stat-card .label{ color: var(--text-muted); font-size:.8rem; }

/* ---------- Badges ---------- */
.badge-admin{ background:#fef3e0; color:#9a5b0a; padding:2px 8px; border-radius:999px; font-size:.72rem; font-weight:700; white-space:nowrap; }
.badge-user{ background: var(--accent-tint); color: var(--accent-dark); padding:2px 8px; border-radius:999px; font-size:.72rem; font-weight:700; white-space:nowrap; }

/* ---------- Admin create-user form ---------- */
.create-form{ display:flex; flex-direction:column; gap:10px; margin-bottom:24px; }
.create-form .field{ margin-bottom:0; width:100%; }
.create-form .btn{ width:100%; }

.back-link{ font-size:.86rem; margin-bottom:14px; display:inline-block; }

/* ---------- Media gallery ---------- */
.gallery-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:12px;
  margin-top: 4px;
}
.media-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  overflow:hidden; box-shadow: var(--shadow);
  display:flex; flex-direction:column;
}
.media-thumb{
  position:relative; width:100%; aspect-ratio: 1/1; background: var(--bg);
  display:flex; align-items:center; justify-content:center; overflow:hidden;
}
.media-thumb img, .media-thumb video{
  width:100%; height:100%; object-fit: cover; display:block;
}
.play-badge{
  position:absolute; bottom:8px; right:8px;
  background: rgba(0,0,0,.55); color:#fff; font-size:.7rem;
  width:24px; height:24px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
}
.generic-icon{
  font-size:.8rem; font-weight:700; color: var(--accent-dark);
  background: var(--accent-tint); width:52px; height:52px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
}
.media-info{ padding: 8px 10px 2px; }
.media-name{
  font-size:.8rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.media-meta{ font-size:.72rem; color: var(--text-muted); margin-top:2px; }
.media-actions{
  display:flex; gap:6px; padding: 8px 10px 10px; margin-top:auto;
}
.media-actions form{ display:contents; }
.media-actions .btn{ flex:1; padding:8px 6px; font-size:.76rem; min-height:36px; }

/* ===== Small phones ===== */
@media (max-width: 380px){
  .gallery-grid{ grid-template-columns: repeat(2, 1fr); gap:8px; }
  .container{ padding: 14px 10px 40px; }
}

/* ===== Tablet and up ===== */
@media (min-width: 640px){
  body{ font-size:16px; }
  .topbar{ padding: 14px 28px; position:static; }
  .topbar-right{ width:auto; }
  .container{ padding: 32px 20px 60px; }
  .card-pad{ padding:24px; }
  .brand{ font-size:1.15rem; }
  .btn.small{ padding:6px 10px; font-size:.8rem; min-height:34px; }
  .section-title h2{ font-size:1.05rem; }
  .stat-grid{ grid-template-columns: repeat(3,1fr); }
  .create-form{ flex-direction:row; flex-wrap:wrap; align-items:flex-end; }
  .create-form .field{ flex:1; min-width:140px; width:auto; }
  .create-form .btn{ width:auto; }
  .gallery-grid{ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap:16px; }
  .media-info{ padding: 10px 12px 4px; }
  .media-name{ font-size:.85rem; }
  .media-meta{ font-size:.76rem; }
  .media-actions{ padding: 10px 12px 12px; gap:8px; }
  .media-actions .btn{ padding:7px 10px; font-size:.82rem; min-height:auto; }
  .login-card h1{ font-size:1.4rem; }
}

/* ===== Desktop ===== */
@media (min-width: 900px){
  .gallery-grid{ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
