/* ═══════════════════════════════════════════════════════════════════════
   Fase 1 — Topbar launcher chrome
   Contiene: topbar sticky, nav horizontal, icon buttons, avatar dropdown,
   body shell. Los tokens de tema vienen de site.css (:root + [data-theme]).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Base ──────────────────────────────────────────────────────────────── */
html, body { height: 100%; }
body {
    background-color: var(--bg-2);
    background-image: radial-gradient(
        ellipse 900px 500px at 0% 0%,
        color-mix(in srgb, var(--color-primario) 10%, transparent) 0%,
        transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

html[data-theme="dark"] body {
    background-color: var(--bg);
    background-image: radial-gradient(
        ellipse 900px 500px at 0% 0%,
        color-mix(in srgb, var(--color-primario) 18%, transparent) 0%,
        transparent 60%);
}

a { color: var(--accent); }
a:hover { color: var(--accent); filter: brightness(0.9); }

/* ── TOPBAR ────────────────────────────────────────────────────────────── */
.topbar {
    background: var(--color-secundario);
    color: var(--color-fuente-secundario);
    border-bottom: 4px solid var(--color-primario);
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1100;
    gap: 24px;
    flex-shrink: 0;
}

/* Brand ------------------------------------------------------------- */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.topbar-brand:hover { color: inherit; text-decoration: none; }

.topbar-brand img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.topbar-brand .brand-text {
    font-family: var(--font-condensed);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.1;
    color: var(--color-fuente-secundario);
}

.topbar-brand .brand-text small {
    display: block;
    font-weight: 400;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    margin-top: 2px;
}

/* Nav links --------------------------------------------------------- */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.topbar-nav a,
.topbar-nav .nav-disabled {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font-family: var(--font-condensed);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    cursor: pointer;
}

.topbar-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-decoration: none;
}

.topbar-nav a.active {
    background: var(--color-primario);
    color: var(--color-fuente-primario);
}

.topbar-nav a.active:hover {
    background: var(--color-primario);
    color: var(--color-fuente-primario);
    filter: brightness(0.92);
}

.topbar-nav .nav-disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
}

.topbar-nav i {
    font-size: 0.95rem;
    line-height: 1;
}

/* Right cluster ----------------------------------------------------- */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;   /* Empuja a la derecha incluso si no hay nav */
}

.icon-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    width: 36px;
    height: 36px;
    border-radius: 4px;
    font-size: 1.05rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.icon-btn[disabled],
.icon-btn.disabled {
    opacity: 0.35;
    cursor: default;
}

/* User avatar dropdown --------------------------------------------- */
.topbar-user {
    position: relative;
}

.topbar-user .user-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 2px;
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.15s;
    display: inline-flex;
    align-items: center;
}

.topbar-user .user-btn:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

.topbar-user .user-btn .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primario);
    color: var(--color-fuente-primario);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    font-family: var(--font-condensed);
    letter-spacing: 0.02em;
}

/* ── MAIN CONTENT AREA ─────────────────────────────────────────────────── */
.app-main {
    flex: 1;
    padding: 16px 28px 48px;
    min-width: 0;
}

/* ── BREADCRUMB BAR (sub-launchers + inner pages — Fase 4/5) ──────────── */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--text-dim);
    font-size: 0.82rem;
}

.breadcrumb-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: var(--text-dim);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.breadcrumb-back:hover {
    background: var(--bg-3);
    color: var(--text);
}

.breadcrumb-path {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.breadcrumb-path li { display: inline-flex; align-items: center; }
.breadcrumb-path li + li::before {
    content: '\F285';  /* bi-chevron-right */
    font-family: 'bootstrap-icons';
    margin-right: 8px;
    opacity: 0.55;
    font-size: 0.7rem;
}
.breadcrumb-path a {
    color: var(--text-dim);
    text-decoration: none;
}
.breadcrumb-path a:hover {
    color: var(--color-primario);
    text-decoration: none;
}
.breadcrumb-path .curr {
    color: var(--text);
    font-weight: 600;
}

/* Actions slot (save-hint + save-btn) — derecha del breadcrumb --------- */
.breadcrumb-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.breadcrumb-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #b87100;   /* warn color */
    font-family: var(--font-body);
}
html[data-theme="dark"] .breadcrumb-hint { color: #ffca6b; }
.breadcrumb-hint i { font-size: 0.88rem; }
/* When used with dirty-watch, hide until form has unsaved changes. */
.breadcrumb-hint[data-dirty-hint]:not(.is-dirty) { display: none; }

.btn-breadcrumb-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: var(--color-primario);
    color: var(--color-fuente-primario);
    border: none;
    border-radius: 4px;
    font-family: var(--font-condensed);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s;
}
.btn-breadcrumb-save:hover { filter: brightness(0.92); }
.btn-breadcrumb-save i { font-size: 0.88rem; }

/* Fase 7.7: Cancel icon-only button, hermano izquierdo del Save. */
.btn-breadcrumb-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    text-decoration: none;
    transition: border-color .15s, color .15s, background .15s;
}
.btn-breadcrumb-cancel:hover {
    border-color: var(--color-primario);
    color: var(--text);
    background: var(--bg-2);
    text-decoration: none;
}
.btn-breadcrumb-cancel i { font-size: 0.85rem; }

/* ── SUB-LAUNCHER hero (simpler than home-hero) ──────────────────────── */
.sub-launcher .sub-hero {
    padding: 4px 0 10px;
    margin-bottom: 8px;
}

.sub-launcher .sub-hero .hero-title {
    font-size: 1.9rem;
    line-height: 1.1;
    margin: 0;
    border: none;
    padding: 0;
}

.sub-launcher .sub-hero .hero-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 4px;
    text-transform: none;
}

/* Sub-launchers usan grid fijo de 3 columnas para que todos los tiles
   mantengan el mismo ancho sin importar cuántos hay en cada grupo
   (evita tiles estirados en grupos con 1 o 2 elementos). */
.sub-launcher .apps-grid {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
    .sub-launcher .apps-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .sub-launcher .apps-grid { grid-template-columns: 1fr; }
}

/* ── DARK THEME overrides ──────────────────────────────────────────────── */
html[data-theme="dark"] .icon-btn {
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="dark"] .icon-btn:hover {
    background: var(--bg-3);
    border-color: var(--text-dim);
    color: var(--text);
}

/* El topbar usa --color-secundario (marca) en ambos temas — se mantiene. */

/* ── RESPONSIVE — Fase 6 pulirá esto; acá solo evitamos rompimiento ──── */
@media (max-width: 991px) {
    .topbar {
        gap: 12px;
        padding: 0 12px;
    }
    .topbar-nav {
        gap: 2px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .topbar-nav::-webkit-scrollbar { display: none; }
    .topbar-nav a,
    .topbar-nav .nav-disabled {
        padding: 6px 10px;
        font-size: 0.82rem;
    }
    .topbar-nav i { display: none; }
    .topbar-brand .brand-text { font-size: 1rem; }
    .topbar-brand .brand-text small { display: none; }
    .app-main { padding: 16px 14px 32px; }
}

@media (max-width: 640px) {
    .topbar-nav a,
    .topbar-nav .nav-disabled {
        padding: 6px 8px;
        font-size: 0.78rem;
    }
    .icon-btn { width: 32px; height: 32px; font-size: 0.95rem; }
}
