/* ─────────────────────────────────────────────────────────
   Catálogo — Design System Pampling (wiki: guias/estetica)
   Poppins · fondo arena · glassmorphism · acento violeta
   ───────────────────────────────────────────────────────── */
:root {
    /* Fondo */
    --bg-base:       #F5F0EB;
    --bg-card:       rgba(255, 255, 255, 0.70);
    --bg-card-2:     rgba(255, 255, 255, 0.90);
    --bg-input:      rgba(255, 255, 255, 0.80);

    /* Bordes */
    --border:        rgba(45, 42, 38, 0.08);
    --border-light:  rgba(45, 42, 38, 0.05);

    /* Texto */
    --text-primary:   #2D2A26;
    --text-secondary: rgba(45, 42, 38, 0.60);
    --text-muted:     rgba(45, 42, 38, 0.35);

    /* Acento principal (violeta) */
    --accent-a:      #7947F8;
    --accent-a-end:  #A855F7;
    --accent-a-grad: linear-gradient(135deg, #7947F8, #A855F7);
    --accent-a-soft: rgba(121, 71, 248, 0.10);

    /* Acento secundario (azul) */
    --accent-b:      #4A9EFF;
    --accent-b-soft: rgba(74, 158, 255, 0.10);

    /* Semánticos */
    --green:      #5C8A6C;
    --green-soft: rgba(92, 138, 108, 0.12);
    --amber:      #C99555;
    --amber-soft: rgba(201, 149, 85, 0.12);
    --red:        #E05252;
    --red-soft:   rgba(224, 82, 82, 0.12);

    /* Radios */
    --radius-sm: 8px;
    --radius:    16px;
    --radius-lg: 20px;

    /* Sombras */
    --shadow:    0 1px 4px rgba(45, 42, 38, 0.06);
    --shadow-md: 0 4px 16px rgba(45, 42, 38, 0.08);

    /* Tipografía */
    --font:      'Poppins', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Layout */
    --nav-height: 60px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* ── Navbar ── */
.topbar {
    background: rgba(245, 240, 235, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent-a-grad);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
}

.brand-text { color: var(--text-primary); font-weight: 700; }

.brand-section {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    padding-left: 10px;
    margin-left: 2px;
    border-left: 1px solid var(--border);
}

.admin-link {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.admin-link:hover { background: var(--accent-a-soft); color: var(--accent-a); }

/* ── Layout ── */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 32px 64px;
    flex: 1;
}
.container-narrow { max-width: 820px; }

/* Encabezado de página (section-tag + h1 + desc) */
.section-tag {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-a);
    margin: 8px 0 6px;
}
.tag-bar {
    width: 24px;
    height: 3px;
    background: var(--accent-a);
    border-radius: 2px;
}

.page-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.page-subtitle, .page-desc {
    color: var(--text-secondary);
    margin: 0 0 28px;
    font-size: 14px;
}

/* ── Index: buscador ── */
.searchbar { margin-bottom: 24px; }
.searchbar input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    box-shadow: var(--shadow);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.searchbar input::placeholder { color: var(--text-muted); }
.searchbar input:focus {
    outline: none;
    border-color: var(--accent-a);
    box-shadow: 0 0 0 3px var(--accent-a-soft);
}

/* ── Index: grid de tarjetas ── */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.app-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 22px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    min-height: 150px;
}
.app-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-a);
}

.app-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.app-card-name {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    word-break: break-word;
}
.app-card-desc {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
}
.app-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
}
.app-card-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-a);
}
.app-card-link:hover { color: var(--accent-a-end); }

.app-card-detail {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.app-card-detail:hover {
    background: var(--accent-a-soft);
    color: var(--accent-a);
    border-color: transparent;
}

.muted-inline { color: var(--text-muted); }

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-secondary);
}
.empty-state p { font-size: 16px; margin: 0 0 18px; }

/* ── Chips / tags / estados ── */
.tag-list, .chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.tag {
    font-size: 12px;
    background: var(--bg-card-2);
    color: var(--text-secondary);
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.chip {
    font-size: 12px;
    font-weight: 600;
    background: var(--accent-a-soft);
    color: var(--accent-a);
    padding: 2px 10px;
    border-radius: 999px;
}

/* Badges de estado — fondo soft + texto semántico (nunca sólido) */
.estado {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
    vertical-align: middle;
    background: var(--green-soft);
    color: var(--green);
}
.estado-desarrollo { background: var(--amber-soft);  color: var(--amber); }
.estado-idea       { background: var(--accent-a-soft); color: var(--accent-a); }
.estado-deprecado  { background: var(--red-soft);    color: var(--red); }

/* ── Cards de admin / secciones ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}
.card-title {
    margin: 0 0 18px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.count-badge {
    background: var(--accent-a-soft);
    color: var(--accent-a);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
}

/* ── Formularios ── */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.form-row input,
.form-row select,
.form-row textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row textarea {
    resize: vertical;
    line-height: 1.55;
    font-family: var(--font-mono);
    font-size: 13px;
}
.form-row input::placeholder,
.form-row textarea::placeholder { color: var(--text-muted); }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--accent-a);
    box-shadow: 0 0 0 3px var(--accent-a-soft);
}
.form-hint { font-size: 12px; color: var(--text-muted); }

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}
.form-error {
    color: var(--red);
    font-size: 13px;
    margin: 0;
    background: var(--red-soft);
    border: 1px solid rgba(224, 82, 82, 0.25);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

/* ── Botones ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 22px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: filter 0.15s, background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--accent-a-grad);
    color: #fff;
}
.btn-primary:hover { filter: brightness(1.07); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--accent-a-soft); color: var(--accent-a); border-color: transparent; }

.btn-danger {
    background: transparent;
    color: var(--red);
    border-color: rgba(224, 82, 82, 0.25);
}
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }

.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ── Lista de apps en admin ── */
.apps-list { display: flex; flex-direction: column; gap: 8px; }
.app-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
}
.app-row:hover { border-color: var(--accent-a); }
.app-row-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.app-row-name {
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.app-row-desc { font-size: 13px; color: var(--text-secondary); }
.app-row-url {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.muted { color: var(--text-muted); text-align: center; padding: 24px 0; margin: 0; font-size: 14px; }

/* ── Modal de ficha ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
    overflow-y: auto;
}
/* `display:flex` anula el display:none del atributo [hidden]; restaurarlo. */
.modal[hidden] { display: none; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(45, 42, 38, 0.40);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.modal-panel {
    position: relative;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 760px;
    width: 100%;
    padding: 32px;
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: transparent;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }
.modal-title { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.modal-sub { margin: 0 0 14px; color: var(--text-secondary); font-size: 15px; }

.meta-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.meta-row { display: flex; gap: 12px; font-size: 14px; }
.meta-label {
    flex: 0 0 110px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-top: 2px;
}
.meta-value { word-break: break-word; }
.meta-value a { color: var(--accent-a); }

.doc { margin-top: 16px; font-size: 14.5px; line-height: 1.65; color: var(--text-primary); }
.doc h1, .doc h2, .doc h3 { margin: 18px 0 8px; font-weight: 700; letter-spacing: -0.3px; }
.doc pre, .doc-pre {
    background: rgba(45, 42, 38, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    font-size: 13px;
    font-family: var(--font-mono);
    white-space: pre-wrap;
}
.doc code {
    background: rgba(45, 42, 38, 0.04);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font-mono);
}
.doc pre code { background: transparent; padding: 0; }
.doc a { color: var(--accent-a); text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .topbar { padding: 0 16px; }
    .container { padding: 20px 16px 48px; }
    .page-title { font-size: 26px; }
    .apps-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .modal-panel { padding: 24px 18px; }
}
