/**
 * app.css — Estilos customizados GarageSale
 * Complementa o Bootstrap 5.3 com o tema SaaS roxo
 */

/* ── Variáveis de tema ────────────────────────── */
:root {
    --sidebar-width:    68px;
    --sidebar-expanded-width: 240px;
    --sidebar-bg:       #1e1145;
    --sidebar-hover:    rgba(255, 255, 255, 0.08);
    --sidebar-active:   #7c3aed;
    --brand-primary:    #7c3aed;
    --brand-secondary:  #a78bfa;
    --topbar-h:         52px;
    --bg-app:           #f4f3ff;
    --text-dark:        #1e1b4b;
}

/* ── Reset / base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    background: var(--bg-app);
    color: var(--text-dark);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}

/* ── Scrollbar customizada (webkit) ──────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 3px; }

/* ════════════════════════════════════════════════
   LAYOUT PRINCIPAL
   ════════════════════════════════════════════════ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: width 0.3s ease, transform 0.3s ease;
}

/* Brand / logo */
.sidebar-brand {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.sidebar-brand img { width: 28px; height: 28px; object-fit: contain; }
.sidebar-brand-fallback {
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
}

/* Links de navegação */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    width: 100%;
    padding: 0 10px;
}
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 0 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.25rem;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    background: transparent;
    border: none;
    cursor: pointer;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.5);
}

/* ── SIDEBAR EXPANDIDA ────────────────────────── */
body.sidebar-expanded .app-sidebar {
    width: var(--sidebar-expanded-width);
}

/* Cabeçalho: logo + nome do app */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 0 14px;
    margin-bottom: 28px;
    overflow: hidden;
    flex-shrink: 0;
}
body.sidebar-expanded .sidebar-header {
    justify-content: flex-start;
}

.sidebar-app-name {
    display: none;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
}
body.sidebar-expanded .sidebar-app-name { display: block; }

/* Rótulos dos links */
.sidebar-label {
    display: none;
    white-space: nowrap;
    overflow: hidden;
    font-size: .875rem;
    font-weight: 500;
}
body.sidebar-expanded .sidebar-label { display: inline; }

/* Links expandidos: alinhamento à esquerda */
body.sidebar-expanded .sidebar-link {
    justify-content: flex-start;
    padding: 0 8px;
    gap: 10px;
}

/* Seta dos grupos retráteis */
.sidebar-arrow {
    display: none;
    margin-left: auto;
    font-size: .7rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}
body.sidebar-expanded .sidebar-arrow { display: inline; }
.sidebar-group-toggle[aria-expanded="true"] .sidebar-arrow {
    transform: rotate(180deg);
}

/* Submenu: visível apenas quando sidebar está expandida */
body:not(.sidebar-expanded) .sidebar-submenu { display: none !important; }
body.sidebar-expanded .sidebar-sublink {
    height: 38px;
    font-size: .825rem;
    padding-left: 36px !important;
}

/* Botão de recolher/expandir sidebar */
.sidebar-collapse-btn {
    background: none;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, .1);
    margin-top: 8px;
    padding-top: 12px;
    border-radius: 0;
    cursor: pointer;
    width: 100%;
    color: rgba(255, 255, 255, .55);
    text-decoration: none;
    transition: background .2s, color .2s;
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: #fff; }

/* ── MAIN ─────────────────────────────────────── */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

body.sidebar-expanded .app-main {
    margin-left: var(--sidebar-expanded-width);
}

/* Topbar mobile */
.app-topbar {
    background: var(--sidebar-bg);
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 900;
}

/* Conteúdo */
.app-content {
    padding: 28px 28px 40px;
    flex: 1;
}

/* ── Overlay para fechar sidebar no mobile ───── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ════════════════════════════════════════════════
   COMPONENTES DE PÁGINA
   ════════════════════════════════════════════════ */

/* Título de página */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* Botão primary (override Bootstrap para a cor da marca) */
.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: #6d28d9;
    border-color: #6d28d9;
}

/* Botão ícone quadrado */
.icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* ── BADGES DE STATUS ─────────────────────────── */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
}
.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-active  { color: #16a34a; background: #dcfce7; }
.badge-on_hold { color: #d97706; background: #fef3c7; }
.badge-draft   { color: #6b7280; background: #f3f4f6; }

/* ── BADGES DE PERCENTUAL ─────────────────────── */
.badge-pct {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    min-width: 52px;
    text-align: center;
}
.badge-pct-high   { color: #16a34a; background: #dcfce7; }  /* >= 80  */
.badge-pct-mid    { color: #d97706; background: #fef3c7; }  /* 40-79  */
.badge-pct-low    { color: #dc2626; background: #fee2e2; }  /* < 40   */

/* ── TABELA ───────────────────────────────────── */
.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    white-space: nowrap;
}
.table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}
.table tbody tr:last-child { border-bottom: none; }

/* ── PAGINAÇÃO ────────────────────────────────── */
.pagination .page-link {
    border-radius: 6px !important;
    margin: 0 2px;
    color: var(--brand-primary);
    border-color: #e5e7eb;
    font-size: .8rem;
}
.pagination .page-item.active .page-link {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* ════════════════════════════════════════════════
   RESPONSIVIDADE MOBILE
   ════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.3);
    }
    .app-main,
    body.sidebar-expanded .app-main {
        margin-left: 0;
    }
    .app-content {
        padding: 16px 16px 32px;
    }
}

@media (max-width: 575.98px) {
    .page-title { font-size: 1.2rem; }
    .app-content { padding: 12px 12px 28px; }
}

/* ── Sidebar: área de usuário logado ─────────── */
.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    color: rgba(255, 255, 255, 0.45);
    overflow: hidden;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    margin-bottom: 4px;
}
body.sidebar-expanded .sidebar-user {
    justify-content: flex-start;
}

/* Botão Sair com tom avermelhado */
.text-danger-soft {
    color: rgba(255, 255, 255, 0.55) !important;
}
.text-danger-soft:hover {
    color: #fca5a5 !important;
    background: rgba(220, 38, 38, 0.15) !important;
}
