/* ============================================================
   portal.css — STK Tech Portal Cliente
   Bootstrap 5.3 · Inter · design system inspirado no NR-1
   ============================================================ */

:root {
    --navy:         #0D1F3C;
    --navy-deep:    #091629;
    --blue:         #1A56DB;
    --blue-dark:    #1648C0;
    --blue-deeper:  #0f3a9e;
    --blue-light:   #EFF6FF;
    --text:         #1E293B;
    --text-muted:   #64748B;
    --border:       #E2E8F0;
    --bg:           #F1F5F9;
    --bg-soft:      #F8FAFC;
    --white:        #FFFFFF;
    --danger:       #DC2626;
    --success:      #16A34A;
    --warning:      #D97706;
    --radius-sm:    8px;
    --radius:       12px;
    --radius-lg:    16px;
    --shadow-sm:    0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow:       0 4px 16px rgba(15,23,42,.08);
    --shadow-lg:    0 8px 32px rgba(15,23,42,.12);
    --shadow-btn:   0 6px 16px rgba(26,86,219,.22);
    --transition:   .18s ease;
    --focus-ring:   0 0 0 0.2rem rgba(26,86,219,.2);
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: .9rem;
    line-height: 1.6;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--blue-dark); }

a:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.dropdown-item:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ── Shell ────────────────────────────────────────────────── */
.portal-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar Backdrop (mobile) ────────────────────────────── */
.sidebar-backdrop {
    background: rgba(9,22,41,.48);
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity .2s ease;
    z-index: 999;
}
body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}
body.sidebar-open .sidebar {
    transform: translateX(0);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: var(--navy);
    color: #fff;
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    padding: 20px 14px 24px;
    overflow-y: auto;
    z-index: 1000;
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.menu-link {
    color: rgba(255,255,255,.72);
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: .85rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.menu-link i { width: 16px; text-align: center; font-size: .8rem; opacity: .8; }
.menu-link:hover  { background: rgba(255,255,255,.1); color: #fff; }
.menu-link.active { background: rgba(26,86,219,.55); color: #fff; }
.menu-link.active i { opacity: 1; }

.menu-group-title {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.35);
    padding: 14px 12px 5px;
    font-weight: 600;
}

/* ── Content ──────────────────────────────────────────────── */
.content {
    flex: 1;
    margin-left: 260px;
    padding: 28px 32px 48px;
    min-height: 100vh;
}

/* ── Auth wrap ────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(ellipse at 20% 30%, rgba(26,86,219,.1) 0%, transparent 50%), var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 460px;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    border-left: 4px solid transparent;
    border-radius: .9rem;
}
.flash.success { background: #f0fdf4; border-left-color: #16a34a; color: #14532d; }
.flash.error   { background: #fff5f5; border-left-color: #dc2626; color: #7f1d1d; }
.flash.warning { background: #fffbea; border-left-color: #d97706; color: #78350f; }
.flash.info    { background: #eff6ff; border-left-color: var(--blue); color: #1e3a8a; }

/* Bootstrap alert overrides com estilo NR-1 */
.alert {
    border: none;
    border-left: 4px solid transparent;
    border-radius: .9rem;
}
.alert-success { background: #f0fdf4; border-left-color: #16a34a; color: #14532d; }
.alert-danger  { background: #fff5f5; border-left-color: #dc2626; color: #7f1d1d; }
.alert-warning { background: #fffbea; border-left-color: #d97706; color: #78350f; }
.alert-info    { background: #eff6ff; border-left-color: var(--blue); color: #1e3a8a; }
.alert-primary { background: #eff6ff; border-left-color: var(--blue); color: #1e3a8a; }

/* ── Page Hero ────────────────────────────────────────────── */
.page-hero {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.page-hero h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 3px;
    line-height: 1.3;
}
.page-hero p {
    font-size: .82rem;
    color: var(--text-muted);
    margin: 0;
}

.page-hero .breadcrumb {
    font-size: .78rem;
    margin: 0 0 8px;
    padding: 0;
    background: none;
}
.page-hero .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.page-hero .breadcrumb-item a { color: var(--blue); text-decoration: none; }
.page-hero .breadcrumb-item a:hover { text-decoration: underline; }
.page-hero .breadcrumb-item.active { color: var(--text-muted); }

/* ── Filter Card ──────────────────────────────────────────── */
.filter-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.filter-card .form-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 4px;
}
.filter-card .form-control,
.filter-card .form-select { border-color: var(--border); font-size: .85rem; }
.filter-card .form-control:focus,
.filter-card .form-select:focus {
    border-color: var(--blue);
    box-shadow: var(--focus-ring);
}

/* ── Table Grid ───────────────────────────────────────────── */
.portal-table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    font-size: .8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
}
.table-counter strong { color: var(--text); }

.portal-table-wrap .table {
    margin: 0;
    font-size: .85rem;
    border-collapse: collapse;
}
.portal-table-wrap .table thead tr { background: var(--bg-soft); }
.portal-table-wrap .table thead th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    border-top: none;
    white-space: nowrap;
    vertical-align: middle;
}
.portal-table-wrap .table tbody tr {
    border-bottom: 1px solid #F1F5F9;
    transition: background var(--transition);
}
.portal-table-wrap .table tbody tr:last-child { border-bottom: none; }
.portal-table-wrap .table tbody tr:hover { background: #F5F9FF; }
.portal-table-wrap .table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
    color: var(--text);
    border-top: none;
}

/* ── Pagination ───────────────────────────────────────────── */
.portal-pagination-wrap {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-soft);
}
.portal-pagination-meta {
    font-size: .77rem;
    color: var(--text-muted);
    width: 100%;
    text-align: center;
}
.portal-pagination-wrap nav { display: flex; justify-content: center; }
.portal-pagination-wrap .pagination { margin: 0; gap: 2px; }
.portal-pagination-wrap .page-link {
    font-size: .8rem;
    padding: 5px 12px;
    border-radius: 999px !important;
    border: 1px solid var(--border);
    color: var(--blue);
    background: var(--white);
    transition: all var(--transition);
    line-height: 1.5;
    margin: 0 2px;
}
.portal-pagination-wrap .page-link:hover {
    background: var(--blue-light);
    border-color: var(--blue);
    color: var(--blue-dark);
}
.portal-pagination-wrap .page-item.active .page-link {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    border-color: var(--blue-dark);
    color: #fff;
    box-shadow: 0 3px 8px rgba(26,86,219,.3);
}
.portal-pagination-wrap .page-item.disabled .page-link {
    color: #CBD5E1;
    border-color: #F1F5F9;
    background: var(--bg-soft);
    pointer-events: none;
}

/* ── Status Badges ────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: .2px;
}

.badge-active, .badge-released, .badge-paid, .badge-open, .badge-conectado {
    background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
}
.badge-inactive, .badge-blocked, .badge-cancelled, .badge-closed, .badge-nao_configurado {
    background: var(--bg-soft); color: #64748b; border: 1px solid var(--border);
}
.badge-pending, .badge-in-progress {
    background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
}
.badge-overdue, .badge-erro {
    background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}
.badge-refunded {
    background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe;
}
.badge-core-admin    { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.badge-core-suporte  { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-cliente-admin { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Action Buttons ───────────────────────────────────────── */
.action-col { white-space: nowrap; text-align: right; }
.action-col .btn {
    font-size: .75rem;
    padding: 4px 9px;
    line-height: 1.4;
    border-radius: var(--radius-sm);
}

/* ── Form Card (páginas de edição) ────────────────────────── */
.form-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.form-card .form-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: linear-gradient(135deg, var(--navy) 0%, color-mix(in srgb, var(--navy) 78%, var(--blue) 22%) 100%);
    border-radius: var(--radius) var(--radius) 0 0;
}
.form-card .form-card-header h2 {
    font-size: .95rem;
    font-weight: 700;
    color: #f0f6ff;
    margin: 0;
}
.form-card .form-card-header p {
    font-size: .8rem;
    color: rgba(255,255,255,.6);
    margin: 3px 0 0;
}
.form-card .form-card-header .text-muted,
.form-card .form-card-header .text-primary { color: rgba(255,255,255,.75) !important; }
.form-card .form-card-header a { color: rgba(255,255,255,.85); }
.form-card .form-card-header a:hover { color: #fff; }

.form-card .form-card-body { padding: 24px; }

.form-card .form-card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Seção dentro do form */
.form-section { margin-bottom: 28px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

/* Form fields */
.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-label .opt { font-weight: 400; color: var(--text-muted); font-size: .78rem; }

.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    padding: 9px 12px;
    min-height: 42px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue);
    box-shadow: var(--focus-ring);
    outline: none;
}
.form-control::placeholder { color: #A0AEC0; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 0.2rem rgba(220,38,38,.18);
}
textarea.form-control { resize: vertical; min-height: 100px; }
.form-text { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-check-input:checked { background-color: var(--blue); border-color: var(--blue); }
.invalid-feedback { font-size: .78rem; }

/* Textarea counter */
.textarea-counter {
    font-size: .78rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
    display: block;
}

/* Password strength */
.password-strength {
    background: #e2e8f0;
    border-radius: 999px;
    height: 5px;
    overflow: hidden;
    margin-top: 8px;
}
.password-strength-bar {
    height: 100%;
    border-radius: 999px;
    transition: width .25s ease, background .25s ease;
    width: 0;
}
.password-strength-text {
    display: block;
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ── Stat Cards (dashboard) ───────────────────────────────── */
.card-stat {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    height: 100%;
    transition: transform var(--transition), box-shadow var(--transition);
}
.card-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* ── Generic card (panels, info boxes) ───────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: linear-gradient(135deg, var(--navy) 0%, color-mix(in srgb, var(--navy) 78%, var(--blue) 22%) 100%);
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #f0f6ff;
    font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-header h1,.card-header h2,.card-header h3,.card-header h4,.card-header h5,.card-header h6 {
    color: #f0f6ff;
}
.card-header .text-muted,
.card-header .text-primary { color: rgba(255,255,255,.75) !important; }
.card-header a { color: rgba(255,255,255,.85); }
.card-header a:hover { color: #fff; }
.card-body { background: var(--white); color: var(--text); }

/* Info panel (lateral nos forms) */
.card-info-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-info-panel .info-panel-header {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
}
.card-info-panel .info-panel-body { padding: 16px; }
.info-item { margin-bottom: 12px; }
.info-item:last-child { margin-bottom: 0; }
.info-item .info-label {
    font-size: .73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    margin-bottom: 3px;
}
.info-item .info-value { font-size: .85rem; color: var(--text); font-weight: 500; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
    background: var(--white);
    padding: 14px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

/* ── Loading / Empty state ────────────────────────────────── */
main.content.is-loading { opacity: .55; pointer-events: none; transition: opacity .25s; }

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state i {
    display: block;
    font-size: 2.4rem;
    margin-bottom: 14px;
    opacity: .28;
}
.empty-state p { font-size: .875rem; margin: 0; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    border-color: var(--blue-dark);
    color: #fff;
    box-shadow: var(--shadow-btn);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue-deeper));
    border-color: var(--blue-deeper);
    color: #fff;
    box-shadow: 0 8px 20px rgba(26,86,219,.32);
}
.btn-primary:active {
    background: var(--blue-deeper);
    box-shadow: none;
}

.btn-outline-primary {
    color: var(--blue);
    border-color: var(--blue);
    background: transparent;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: rgba(26,86,219,.08);
    border-color: var(--blue-dark);
    color: var(--blue-dark);
}

.btn-outline-danger:hover { background: rgba(220,38,38,.08); }
.btn-outline-secondary:hover { background: rgba(100,116,139,.1); }

.btn-sm { font-size: .8rem; padding: 5px 12px; border-radius: var(--radius-sm); }
.btn-xs { font-size: .72rem; padding: 3px 9px; border-radius: 6px; }

/* Focus rings */
.btn:focus-visible     { box-shadow: var(--focus-ring); outline: none; }
.btn-primary:focus     { box-shadow: var(--shadow-btn), var(--focus-ring); }

/* ── Session timeout modal ────────────────────────────────── */
#sessionTimeoutModal .modal-content {
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    .content { margin-left: 0; padding: 16px; }
}
@media (max-width: 576px) {
    .page-hero { padding: 16px; }
    .filter-card { padding: 14px; }
    .portal-table-wrap .table thead th,
    .portal-table-wrap .table tbody td { padding: 9px 12px; }
    .form-card .form-card-body,
    .form-card .form-card-header { padding: 16px; }
}
