/* ══════════════════════════════════════════════════════════════════════════
 * Brand Assets — vertical-left-sidebar shell (Mother-CRM pattern)
 *
 * Same shell as Voice Studio sidebar (2026-05-11 Rafa request "lo mismo
 * para donde guardamos los assets"). 240px dark sidebar + 1fr main box.
 * Category filters live in the sidebar; search + Upload action live in
 * the top of the main box.
 * ══════════════════════════════════════════════════════════════════════════ */

:root {
  --am-sidebar-w: 240px;
  --am-sidebar-bg: #1a1410;
  --am-sidebar-fg: #faf6ee;
  --am-sidebar-fg-muted: rgba(250, 246, 238, 0.62);
  --am-sidebar-border: rgba(212, 190, 149, 0.18);
  --am-sidebar-active-bg: rgba(212, 190, 149, 0.14);
  --am-sidebar-active-fg: #d4be95;
  --am-canvas-bg: #ede2ca;
  --am-gap: 12px;
}

html, body { height: 100%; overflow: hidden; margin: 0; }
body { background: var(--am-canvas-bg); min-height: 100vh; }

/* ─── Two-column shell ────────────────────────────────────────────────── */
.am-shell {
  display: grid;
  grid-template-columns: var(--am-sidebar-w) 1fr;
  gap: var(--am-gap);
  padding: var(--am-gap);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background: var(--am-canvas-bg);
}

/* ─── Sidebar ─────────────────────────────────────────────────────────── */
.am-sidebar {
  background: var(--am-sidebar-bg);
  color: var(--am-sidebar-fg);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--am-sidebar-border);
  box-shadow: 0 1px 2px rgba(26, 20, 16, 0.06), 0 8px 24px rgba(26, 20, 16, 0.04);
  position: sticky;
  top: var(--am-gap);
  height: calc(100vh - 2 * var(--am-gap));
  overflow-y: auto;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif);
}

.am-sidebar-brand {
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--am-sidebar-border);
  position: sticky;
  top: 0;
  background: var(--am-sidebar-bg);
  z-index: 3;
  border-radius: 12px 12px 0 0;
}
.am-sidebar-logo {
  width: 92%;
  height: auto;
  display: block;
  margin: 0 auto 10px;
  filter: brightness(0) invert(1);
}
.am-sidebar-back {
  display: block;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--am-sidebar-fg-muted);
  text-decoration: none;
  padding: 6px 4px;
  border-radius: 6px;
  transition: color 120ms ease, background 120ms ease;
}
.am-sidebar-back:hover {
  color: var(--am-sidebar-active-fg);
  background: rgba(255, 255, 255, 0.04);
}

.am-sidebar-nav { flex: 1; padding: 8px 0; }

.am-side-section { padding: 14px 0; }
.am-side-label {
  padding: 0 18px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--am-sidebar-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

.am-side-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 18px;
  color: var(--am-sidebar-fg-muted);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  border: none;
  background: transparent;
  border-left: 3px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.am-side-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.am-side-link.is-active {
  background: var(--am-sidebar-active-bg);
  color: var(--am-sidebar-active-fg);
  font-weight: 500;
  border-left-color: var(--am-sidebar-active-fg);
}

.am-sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--am-sidebar-border);
  background: var(--am-sidebar-bg);
  border-radius: 0 0 12px 12px;
  font-size: 11px;
  color: var(--am-sidebar-fg-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.am-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #5e8c4f;
  box-shadow: 0 0 8px #5e8c4f;
  display: inline-block;
}

/* ─── Main scroll-box ─────────────────────────────────────────────────── */
.am-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100vh - 2 * var(--am-gap));
  overflow: hidden;
  background: var(--bg-cream, #faf6ee);
  border-radius: 12px;
  border: 1px solid rgba(212, 190, 149, 0.25);
  box-shadow: 0 1px 2px rgba(26, 20, 16, 0.04);
}

.am-topbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-soft, rgba(212, 190, 149, 0.30));
  background: var(--bg-cream, #faf6ee);
  border-radius: 12px 12px 0 0;
  gap: 16px;
  flex-wrap: wrap;
}
.am-topbar-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.am-topbar-title .am-title {
  font-family: var(--font-serif, Georgia, serif);
  font-style: italic;
  font-weight: 500;
  font-size: 22px;
  margin: 0;
  color: var(--fg-charcoal, #1a1410);
}
.am-topbar-title .am-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--fg-soft, #7a6b58);
}
.am-topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.am-topbar-actions .am-search-box { flex: 0 0 220px; }

/* ─── Content area scrolls inside main ────────────────────────────────── */
.am-shell .am-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  max-width: none;
  margin: 0;
  width: 100%;
}

/* ─── Hide legacy header (now in sidebar/topbar) ──────────────────────── */
.am-shell .am-app .am-header,
.am-shell .am-header { display: none !important; }

/* ─── Mobile responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .am-shell { grid-template-columns: 1fr; height: auto; overflow: visible; }
  html, body { overflow: auto; }
  .am-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: wrap;
  }
  .am-sidebar-brand { width: 100%; }
  .am-sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; flex: 1; }
  .am-side-section { padding: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
  .am-side-label { display: none; }
  .am-side-link { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--am-sidebar-border); border-left: 1px solid var(--am-sidebar-border); }
  .am-side-link.is-active { border-color: var(--am-sidebar-active-fg); }
  .am-main { height: auto; min-height: 70vh; }
}

/* ══════════════════════════════════════════════════════════════════════ */

html, body { height: 100%; overflow: hidden; margin: 0; }

/* Marcus OS Brand Assets Manager — visual coherence with Voice Studio */

:root {
  --bg-cream: #faf6ee;
  --bg-paper: #fffdf7;
  --fg-charcoal: #1a1410;
  --fg-mid: #4a3f33;
  --fg-soft: #7a6b58;
  --accent-brass: #d4be95;
  --accent-brass-dark: #8b6914;
  --accent-brass-light: rgba(212, 190, 149, 0.15);
  --border-soft: rgba(212, 190, 149, 0.30);
  --danger: #b5483a;
  --success: #5e8c4f;

  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  --shadow-card: 0 1px 2px rgba(26,20,16,0.06), 0 8px 24px rgba(26,20,16,0.04);
  --radius-card: 12px;
  --radius-input: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-cream);
  color: var(--fg-charcoal);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────── */
.am-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  max-width: 1400px; margin: 0 auto; padding: 24px 32px 64px;
}

.am-header {
  flex-shrink: 0;
  background: var(--bg-cream, #faf6ec);
   padding: 16px 0 24px; border-bottom: 1px solid var(--border-soft); margin-bottom: 24px; }
.am-back-link { color: var(--accent-brass-dark); text-decoration: none; font-size: 13px; letter-spacing: 0.04em; }
.am-back-link:hover { color: var(--fg-charcoal); }

.am-brand-row { display: flex; align-items: center; gap: 14px; margin: 14px 0 8px; }
.am-brand-image { width: 240px; height: auto; display: block; }

.am-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; margin-top: 12px; }
.am-title { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 36px; margin: 0 0 6px; color: var(--fg-charcoal); }
.am-subtitle { color: var(--fg-soft); font-size: 14px; margin: 0; }
.am-badge { display: inline-block; padding: 2px 8px; background: var(--fg-charcoal); color: var(--bg-paper); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; border-radius: 3px; margin-left: 6px; vertical-align: middle; }

/* ── Buttons ────────────────────────────────────────────── */
.am-btn { padding: 10px 18px; border: 1px solid var(--fg-charcoal); border-radius: var(--radius-input); font-family: var(--font-sans); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 120ms ease; letter-spacing: 0.02em; }
.am-btn-primary { background: var(--fg-charcoal); color: var(--bg-paper); }
.am-btn-primary:hover { background: var(--fg-mid); }
.am-btn-primary:disabled { background: var(--fg-soft); cursor: wait; }
.am-btn-ghost { background: transparent; color: var(--fg-charcoal); border-color: var(--border-soft); }
.am-btn-ghost:hover { background: var(--accent-brass-light); }
.am-btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.am-btn-danger:hover { background: #8a3729; }

/* ── Filters ────────────────────────────────────────────── */
.am-filters { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.am-filter-group { display: flex; gap: 8px; flex-wrap: wrap; }
.am-chip { background: transparent; border: 1px solid var(--border-soft); border-radius: 999px; padding: 6px 14px; font-size: 12px; letter-spacing: 0.04em; color: var(--fg-mid); cursor: pointer; transition: all 120ms ease; }
.am-chip:hover { border-color: var(--accent-brass-dark); color: var(--fg-charcoal); }
.am-chip-active { background: var(--fg-charcoal); color: var(--bg-paper); border-color: var(--fg-charcoal); }

.am-search-box { flex: 0 0 260px; }
.am-search-box input { width: 100%; padding: 8px 14px; border: 1px solid var(--border-soft); border-radius: var(--radius-input); background: var(--bg-paper); font-family: var(--font-sans); font-size: 13px; color: var(--fg-charcoal); }
.am-search-box input:focus { outline: none; border-color: var(--accent-brass-dark); }

/* ── Stats ──────────────────────────────────────────────── */
.am-stats { display: flex; gap: 32px; padding: 12px 0; margin-bottom: 12px; border-bottom: 1px solid var(--border-soft); font-size: 12px; color: var(--fg-soft); letter-spacing: 0.06em; text-transform: uppercase; }
.am-stat-num { font-family: var(--font-serif); font-style: italic; font-size: 18px; font-weight: 400; color: var(--fg-charcoal); margin-right: 6px; text-transform: none; letter-spacing: 0; }

/* ── Grid ───────────────────────────────────────────────── */
.am-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.am-empty-state { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: var(--fg-soft); font-style: italic; }

/* ── Card ───────────────────────────────────────────────── */
.am-card { background: var(--bg-paper); border: 1px solid var(--border-soft); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; transition: transform 120ms ease, box-shadow 120ms ease; cursor: pointer; }
.am-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(26,20,16,0.10), 0 16px 40px rgba(26,20,16,0.08); }
.am-card-preview { width: 100%; aspect-ratio: 1; background: repeating-linear-gradient(45deg, #f0ead8 0 8px, #faf6ee 8px 16px); display: flex; align-items: center; justify-content: center; padding: 12px; }
.am-card-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.am-card-preview-dark { background: var(--fg-charcoal); }
.am-card-body { padding: 12px 14px; }
.am-card-slug { font-family: monospace; font-size: 12px; color: var(--fg-charcoal); margin-bottom: 4px; word-break: break-all; }
.am-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--fg-soft); }
.am-card-cat { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--accent-brass-light); color: var(--accent-brass-dark); }

/* ── Modal ──────────────────────────────────────────────── */
.am-modal-backdrop[hidden] { display: none !important; }
.am-modal-backdrop { position: fixed; inset: 0; background: rgba(26,20,16,0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.am-modal { background: var(--bg-paper); border-radius: var(--radius-card); max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.am-modal-detail { max-width: 720px; }
.am-modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.am-modal-header h2 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 22px; margin: 0; }
.am-modal-close { background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--fg-soft); padding: 0 8px; }
.am-modal-close:hover { color: var(--fg-charcoal); }
.am-modal-body { padding: 24px; }
.am-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border-soft); margin-top: 16px; }

.am-form-row { margin-bottom: 18px; }
.am-form-label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-soft); margin-bottom: 6px; }
.am-form-row input[type=text],
.am-form-row input[type=file] { width: 100%; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: var(--radius-input); background: var(--bg-paper); font-family: var(--font-sans); font-size: 13px; }
.am-form-row input:focus { outline: none; border-color: var(--accent-brass-dark); }
.am-form-hint { display: block; font-size: 11px; color: var(--fg-soft); margin-top: 4px; }

#am-upload-status { padding: 10px 14px; border-radius: var(--radius-input); font-size: 13px; }
#am-upload-status.success { background: rgba(94,140,79,0.10); color: var(--success); border: 1px solid rgba(94,140,79,0.30); }
#am-upload-status.error { background: rgba(181,72,58,0.10); color: var(--danger); border: 1px solid rgba(181,72,58,0.30); }

.am-detail-preview { width: 100%; max-height: 320px; aspect-ratio: 1; background: repeating-linear-gradient(45deg, #f0ead8 0 8px, #faf6ee 8px 16px); display: flex; align-items: center; justify-content: center; padding: 16px; border-radius: 8px; margin-bottom: 16px; }
.am-detail-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.am-detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.am-detail-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.am-detail-table td:first-child { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-soft); width: 30%; }
.am-detail-table td:last-child { font-family: monospace; word-break: break-all; }
.am-detail-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }

/* ── Toast ──────────────────────────────────────────────── */
.am-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--fg-charcoal); color: var(--bg-paper); padding: 12px 24px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 2000; }
.am-toast.error { background: var(--danger); }
.am-toast.success { background: var(--success); }
