/* ============================================================
   Mileto CRM - Shell (sidebar, topbar) e componentes base
   ============================================================ */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
    color: #c7d2e4;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    color: #fff;
}

.sidebar__logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-500), var(--accent-700));
    color: #fff;
    box-shadow: var(--shadow);
}

.sidebar__title { font-size: 18px; font-weight: 500; letter-spacing: 0.2px; }
.sidebar__title strong { font-weight: 800; }

.sidebar__nav {
    padding: var(--sp-3) var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-3);
    border-radius: var(--radius-sm);
    color: #aebdd4;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--accent-600); color: #fff; box-shadow: var(--shadow-sm); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item__badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: rgba(255, 255, 255, 0.12);
    color: #cdd8ea;
    padding: 2px 6px;
    border-radius: 999px;
}

.sidebar__footer { padding: var(--sp-4); border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar__user { display: flex; align-items: center; gap: var(--sp-3); }
.sidebar__user-info { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar__user-name { color: #fff; font-weight: 600; }
.sidebar__user-role { color: #8295b3; font-size: 12px; }

.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-400), var(--accent-700));
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}

/* ---------- Main / Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__title { font-size: 20px; font-weight: 700; }
.topbar__subtitle { color: var(--text-muted); font-size: 13px; }
.topbar__actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; justify-content: flex-end; }

.content { padding: var(--sp-6); flex: 1; outline: none; }

/* ---------- Botoes ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--accent-500); border-color: var(--accent-500); color: #fff; }
.btn--primary:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.input, .select {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-50); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge--success { background: var(--success-50); color: var(--success-500); }
.badge--warning { background: var(--warning-50); color: var(--warning-500); }
.badge--danger { background: var(--danger-50); color: var(--danger-500); }
.badge--info { background: var(--info-50); color: var(--info-500); }
.badge--muted { background: var(--surface-2); color: var(--text-muted); }

/* ---------- Cards / paineis ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ---------- Estados ---------- */
.state {
    display: grid;
    place-items: center;
    text-align: center;
    padding: var(--sp-7) var(--sp-5);
    gap: var(--sp-3);
    color: var(--text-muted);
}
.state__icon {
    width: 56px; height: 56px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent-50);
    color: var(--accent-500);
}
.state__title { font-size: 16px; font-weight: 700; color: var(--text); }

/* ---------- Skeleton ---------- */
.skeleton {
    position: relative;
    overflow: hidden;
    background: #eef1f6;
    border-radius: var(--radius-sm);
}
.skeleton::after {
    content: "";
    position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- Toast ---------- */
.toast-stack {
    position: fixed;
    right: var(--sp-5);
    bottom: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    z-index: 100;
}
.toast {
    background: var(--brand-900);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    max-width: 320px;
    animation: toast-in 0.2s ease;
}
.toast--error { background: var(--danger-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 50; width: var(--sidebar-w); transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.is-open { transform: none; }
    .content { padding: var(--sp-4); }
    .topbar { padding: 0 var(--sp-4); }
}
