/* Painel Admin - mesmo banco, Hostinger */
:root {
    --bg: #f0f2f5;
    --card: #fff;
    --primary: #5A4D7A;
    --primary-light: #4A7BA7;
    --text: #1c1b1f;
    --text-muted: #5a5a5a;
    --border: #e0e0e0;
    --success: #2e7d32;
    --warning: #ed6c02;
    --error: #b00020;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

/* ----- Login ----- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    background: var(--card); border-radius: 16px; padding: 32px; max-width: 380px; width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.login-card h1 { margin: 0 0 4px; font-size: 1.5rem; color: var(--primary); }
.login-card .subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: 0.9rem; }
.login-card label { display: block; margin: 12px 0 4px; font-size: 0.9rem; font-weight: 500; }
.login-card input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 1rem;
}
.login-card .btn { margin-top: 20px; width: 100%; padding: 12px; font-size: 1rem; }
.login-logo-wrap { text-align: center; margin-bottom: 24px; }
.login-logo { max-width: 100%; max-height: 80px; width: auto; height: auto; object-fit: contain; display: block; margin: 0 auto; }
.alert { padding: 12px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #ffebee; color: var(--error); }
.alert-warning { background: #fff3e0; color: #e65100; }
.alert-success { background: #e8f5e9; color: var(--success); }

/* ----- Dashboard layout: sidebar até o topo, altura total ----- */
.dashboard { display: flex; min-height: 100vh; margin: 0; }
html, body { margin: 0; }

.sidebar {
    width: 280px; min-width: 280px; height: 100vh; position: sticky; top: 0; left: 0;
    background: linear-gradient(180deg, #4a3f6a 0%, #3d3559 40%, #352d4a 100%);
    color: #fff; display: flex; flex-direction: column; flex-shrink: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
    border-radius: 0 16px 16px 0;
    margin-right: 12px;
    overflow: hidden;
}

/* Brand: ícone em caixa + título e subtítulo (sem linha abaixo) */
.sidebar-brand {
    padding: 24px 20px 8px; display: flex; align-items: center; gap: 14px;
}
.sidebar-brand-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand-icon i { font-size: 1.4rem; opacity: .95; }
.sidebar-brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar-brand-title { font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; }
.sidebar-brand-subtitle { font-size: 0.75rem; opacity: .75; font-weight: 500; }
.sidebar-brand-logo { max-width: 100%; max-height: 48px; width: auto; height: auto; object-fit: contain; display: block; }

.sidebar-subtitle {
    padding: 0 20px 16px; font-size: 0.8rem; line-height: 1.3; color: rgba(255,255,255,.85);
    text-align: center; border-bottom: 1px solid rgba(255,255,255,.12);
}

/* Label "Menu" acima dos itens */
.sidebar-nav-label {
    padding: 20px 20px 8px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .08em; opacity: .6;
}

.sidebar-nav { flex: 1; padding: 0 12px 16px; overflow-y: auto; min-height: 0; }
.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 2px;
    color: rgba(255,255,255,.88); text-decoration: none; font-size: 0.95rem;
    border-radius: 10px; transition: background .2s, color .2s;
    position: relative; border-left: 3px solid transparent;
}
.sidebar-nav .nav-item i {
    font-size: 1.2rem; width: 26px; text-align: center; opacity: .9; flex-shrink: 0;
}
.sidebar-nav .nav-item:hover {
    background: rgba(255,255,255,.1); color: #fff;
}
.sidebar-nav .nav-item.active {
    background: rgba(255,255,255,.16); color: #fff; font-weight: 600;
    border-left-color: #fff; padding-left: 13px;
}
.sidebar-nav .nav-item.active i { opacity: 1; }

/* Scrollbar discreta na nav */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

/* Footer: card do usuário + botão Sair */
.sidebar-footer {
    padding: 16px 12px 20px; border-top: 1px solid rgba(255,255,255,.12);
    display: flex; flex-direction: column; gap: 10px; flex-shrink: 0;
}
.sidebar-user-card {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    background: rgba(255,255,255,.08); border-radius: 10px; border: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-card i { font-size: 1.5rem; opacity: .9; flex-shrink: 0; }
.sidebar-user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar-user-name { font-size: 0.9rem; font-weight: 600; }
.sidebar-user-role { font-size: 0.75rem; opacity: .8; }

.sidebar-footer .nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    color: rgba(255,255,255,.88); text-decoration: none; font-size: 0.9rem;
    border-radius: 8px; transition: background .2s;
}
.sidebar-footer .nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-footer .nav-item i { font-size: 1.1rem; flex-shrink: 0; }
.nav-item-logout { color: rgba(255,255,255,.85); }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 14px 24px; display: flex; align-items: center; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.topbar .brand { font-weight: 600; font-size: 1.1rem; color: var(--text); }

.content { flex: 1; padding: 24px; overflow: auto; }
.content h1 { margin: 0 0 8px; font-size: 1.5rem; }
.content .muted { margin: 0 0 20px; color: var(--text-muted); font-size: 0.9rem; }

/* ----- Cards (dashboard) ----- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 32px; }
.card {
    background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
    display: flex; flex-direction: column; gap: 4px;
}
.card-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.card-label { font-size: 0.85rem; color: var(--text-muted); }

/* ----- Section & Table ----- */
.section { margin-top: 24px; }
.section h2 { font-size: 1.1rem; margin: 0 0 12px; color: var(--text); }
.table {
    width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg); font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(0,0,0,.02); }
.table code { font-size: 0.9em; background: var(--bg); padding: 2px 6px; border-radius: 4px; }

.badge { display: inline-block; padding: 4px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 500; }

/* ----- Paginação ----- */
.pagination-wrap { margin-top: 20px; }
.pagination {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0;
}
.pagination li { display: inline-block; }
.pagination-link {
    display: inline-block; padding: 8px 12px; border-radius: 8px; font-size: 0.9rem;
    color: var(--primary); text-decoration: none; border: 1px solid var(--border); background: var(--card);
    transition: background .15s, border-color .15s;
}
.pagination-link:hover { background: var(--bg); border-color: var(--primary); }
.pagination-link.active {
    background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600;
}
.pagination-link.disabled { color: var(--text-muted); cursor: not-allowed; opacity: .7; }
.pagination-link.disabled:hover { background: var(--card); border-color: var(--border); }
.pagination-ellipsis { padding: 8px 6px; color: var(--text-muted); font-size: 0.9rem; }

/* ----- Buttons ----- */
.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: 8px; font-size: 1rem; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4a4070; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d0d0d0; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #9a0018; }
.btn-sm { padding: 6px 12px; font-size: 0.9rem; }
.page-header-flex { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.clientes-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.clientes-toolbar .form-label-inline { margin: 0; font-size: 0.9rem; }
.clientes-toolbar .form-select-inline { width: auto; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.page-header-flex h1 { margin: 0 0 4px; }
.page-header-flex .muted { margin: 0; }
/* Linha clicável para abrir visualização */
.clientes-row-click { cursor: pointer; transition: background-color 0.15s ease; }
.clientes-row-click:hover { background-color: rgba(0, 0, 0, 0.04); }
.table-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.table-actions .btn { margin: 0; min-width: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.table-actions .btn-action-edit { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.table-actions .btn-action-edit:hover { background: #bbdefb; color: #0d47a1; }
.table-actions .btn-action-delete { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.table-actions .btn-action-delete:hover { background: #ffcdd2; color: #b71c1c; }
@media (max-width: 640px) {
    .table-actions .btn-action-text { display: none; }
}
.form-inline-delete { display: inline; }
.form-inline-delete .btn { margin: 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* ----- Configurações (logos) ----- */
.config-form { max-width: 640px; }
.config-section {
    background: var(--card); border-radius: 12px; padding: 24px; margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.config-section h2 { margin: 0 0 4px; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.config-section h2 i { color: var(--primary); }
.config-section .muted { margin: 0 0 16px; }
.logo-preview-wrap { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.logo-preview { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.logo-preview-img { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.logo-preview-img-login { max-height: 80px; width: auto; }
.logo-preview-img-sidebar { max-height: 48px; max-width: 220px; width: auto; }
.btn-remove-logo { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-remove-logo:hover { background: #ffebee; color: var(--error); border-color: #ffcdd2; }
.no-logo { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 12px; }
.logo-upload { position: relative; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Esconde o "Escolher arquivo" nativo; só o botão "Escolher imagem" fica visível */
.logo-upload input[type="file"] {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}
.config-field { margin-top: 8px; }
.config-field label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.config-input { width: 100%; max-width: 400px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; }
.config-textarea { max-width: 100%; min-height: 60px; resize: vertical; }
.config-select { max-width: 240px; cursor: pointer; }
.config-actions { margin-top: 8px; }
.label-required { color: var(--error); }

/* Formulário cliente em duas colunas */
.cliente-form-two-cols.config-form { max-width: 900px; }
.cliente-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 32px;
    margin-bottom: 20px;
}
.cliente-form-col .config-input { max-width: 100%; }
.cliente-form-actions { margin-top: 16px; }
@media (max-width: 768px) {
    .cliente-form-grid { grid-template-columns: 1fr; }
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .dashboard { flex-direction: column; }
    .sidebar {
        width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap;
        padding: 12px 16px; gap: 0;
    }
    .sidebar-brand { width: 100%; padding: 12px 0 16px; }
    .sidebar-brand-icon { width: 40px; height: 40px; }
    .sidebar-brand-icon i { font-size: 1.2rem; }
    .sidebar-nav-label { padding: 8px 0 8px; }
    .sidebar-nav { flex: none; width: 100%; padding: 0 0 12px; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .sidebar-nav .nav-item { margin-bottom: 0; }
    .sidebar-footer { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 0 0; flex-wrap: wrap; gap: 8px; }
    .sidebar-user-card { flex: 1; min-width: 140px; }
    .sidebar-user-info { overflow: hidden; }
    .sidebar-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .cards { grid-template-columns: repeat(2, 1fr); }
    .table { font-size: 0.9rem; }
    .table th, .table td { padding: 10px 12px; }
}
