/*
   WhatsAuto Portal · UI refresh inspired by the clean CRM workspace language
   requested by the user. Visual-only layer: no business logic or markup flow
   is changed by this stylesheet.
*/
:root {
    --sidebar-width: 284px;
    --topbar-height: 64px;
    --portal-bg: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #fafbfc;
    --surface-hover: #f3f6fb;
    --border: #e3e7ed;
    --border-strong: #d5dae2;
    --text: #242a35;
    --text-strong: #171c26;
    --muted: #7d8594;
    --muted-2: #9aa1ad;
    --primary: #4b8df8;
    --primary-hover: #3478e5;
    --primary-soft: #eaf2ff;
    --primary-soft-hover: #deebff;
    --success: #35a36f;
    --danger: #e96464;
    --warning: #d79a32;
    --radius-sm: 7px;
    --radius-md: 10px;
    --radius-lg: 13px;
    --shadow-soft: 0 1px 2px rgba(22, 28, 45, .03), 0 6px 18px rgba(22, 28, 45, .035);
    --shadow-float: 0 12px 34px rgba(22, 28, 45, .10);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--portal-bg); }
body {
    margin: 0;
    background: var(--portal-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    letter-spacing: -.005em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Top bar */
.navbar.navbar-dark.bg-dark {
    min-height: var(--topbar-height);
    padding: 0 20px;
    background: rgba(255,255,255,.97) !important;
    border-bottom: 1px solid var(--border);
    box-shadow: none !important;
    backdrop-filter: blur(10px);
}
.navbar .container-fluid { min-height: var(--topbar-height); padding: 0; }
.navbar-dark .navbar-brand,
.navbar .navbar-brand {
    color: var(--text-strong) !important;
    font-size: 18px;
    font-weight: 700 !important;
    letter-spacing: -.02em;
}
.navbar .text-white,
.navbar .text-white-50 { color: var(--muted) !important; }
.navbar .badge.text-bg-light {
    color: #3d4758 !important;
    background: #f2f4f7 !important;
    border: 1px solid var(--border);
    font-weight: 600;
    padding: .42rem .68rem;
}
.navbar .btn-outline-light {
    color: #576172;
    background: #fff;
    border-color: var(--border-strong);
}
.navbar .btn-outline-light:hover {
    color: var(--text-strong);
    background: var(--surface-hover);
    border-color: #c9d0da;
}
#sidebarToggle {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
}

/* App shell */
.portal-shell {
    display: flex;
    min-height: calc(100vh - var(--topbar-height));
}
.portal-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    scrollbar-width: thin;
    scrollbar-color: #d7dce4 transparent;
}
.portal-sidebar::-webkit-scrollbar { width: 6px; }
.portal-sidebar::-webkit-scrollbar-thumb { background: #d7dce4; border-radius: 6px; }
.portal-sidebar > .p-3 {
    padding: 22px 22px 18px !important;
    border-bottom-color: var(--border) !important;
}
.portal-sidebar .text-uppercase.small {
    color: var(--muted-2) !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
}
.portal-sidebar .fw-semibold.mt-1 {
    color: var(--text-strong);
    margin-top: 7px !important;
    font-size: 15px;
    font-weight: 650 !important;
}
.portal-sidebar .small.text-secondary { color: var(--muted) !important; }
.portal-sidebar nav.nav {
    padding: 12px 10px 18px !important;
    gap: 3px !important;
}
.portal-nav {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 42px;
    color: #4b5565;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 500;
    transition: color .15s ease, background .15s ease, transform .15s ease;
}
.portal-nav:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}
.portal-nav.active {
    background: var(--primary-soft);
    color: #2e6fda;
    font-weight: 650;
}
.portal-nav.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}
.portal-sidebar hr {
    border-color: var(--border) !important;
    opacity: 1;
    margin: 10px 6px !important;
}
.portal-main { flex: 1; min-width: 0; background: var(--portal-bg); }
.portal-main > .container-fluid {
    padding: 30px 34px 42px !important;
    max-width: 1800px;
    margin: 0 auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { color: var(--text-strong); letter-spacing: -.025em; }
h1.h3, .h3 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.25;
}
.h5 { font-weight: 650; }
.text-secondary { color: var(--muted) !important; }
.small { font-size: .875rem; }

/* Cards / panels */
.card {
    border-color: var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}
.section-card,
.metric-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}
.section-card .card-header,
.card-header {
    min-height: 50px;
    background: #fff !important;
    border-bottom: 1px solid var(--border);
    color: var(--text-strong);
    padding: 14px 18px;
}
.section-card .card-body { background: #fff; }
.metric-card {
    height: 100%;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.metric-card:hover {
    border-color: #d4dbe6 !important;
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}
.metric-card .card-body { padding: 19px 20px; }
.metric-value {
    color: var(--text-strong);
    font-size: 29px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -.035em;
}
.company-card { transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.company-card:hover {
    transform: translateY(-2px);
    border-color: #cfd7e3 !important;
    box-shadow: 0 10px 24px rgba(22,28,45,.07);
}

/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    min-height: 38px;
    padding: .5rem .9rem;
    box-shadow: none !important;
}
.btn-sm { min-height: 32px; padding: .35rem .65rem; font-size: 13px; }
.btn-lg { min-height: 46px; font-size: 15px; }
.btn-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    color: #fff !important;
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}
.btn-outline-primary {
    color: #3978de;
    background: #fff;
    border-color: #a9c7f7;
}
.btn-outline-primary:hover {
    color: #2f6fd5;
    background: var(--primary-soft);
    border-color: #91b8f3;
}
.btn-outline-secondary {
    color: #596476;
    background: #fff;
    border-color: var(--border-strong);
}
.btn-outline-secondary:hover {
    color: var(--text-strong);
    background: #f3f5f8;
    border-color: #c8cfd9;
}
.btn-outline-success { color: #25865c; border-color: #a9d6c4; background: #fff; }
.btn-outline-success:hover { color: #216f50; background: #edf8f3; border-color: #8ecab2; }
.btn-outline-danger { color: #d95a5a; border-color: #efbaba; background: #fff; }
.btn-outline-danger:hover { color: #bf4848; background: #fff0f0; border-color: #e9a3a3; }

/* Inputs */
.form-label {
    color: #4e5868;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
.form-control,
.form-select {
    min-height: 40px;
    color: var(--text);
    background-color: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: .52rem .72rem;
    font-size: 14px;
    box-shadow: inset 0 1px 1px rgba(22,28,45,.015);
}
.form-control::placeholder { color: #a2a9b4; }
.form-control:focus,
.form-select:focus {
    color: var(--text);
    background-color: #fff;
    border-color: #8db7f7;
    box-shadow: 0 0 0 3px rgba(75,141,248,.12);
}
.form-control:disabled,
.form-select:disabled {
    color: #7f8793;
    background: #f5f6f8;
    border-color: #e1e5eb;
}
.form-check-input { border-color: #c6ccd6; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: #8db7f7; box-shadow: 0 0 0 3px rgba(75,141,248,.12); }
.form-text { color: var(--muted); font-size: 12px; }

/* Tables */
.table-scroll {
    width: 100%;
    max-height: calc(100vh - 285px);
    overflow: auto;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    scrollbar-width: thin;
    scrollbar-color: #d4dae3 transparent;
}
.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: #d4dae3; border-radius: 8px; }
.table-scroll table { min-width: 980px; margin-bottom: 0; }
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f8fafc;
    color: var(--text);
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    padding: .78rem .88rem;
    border-bottom-color: #edf0f4;
    vertical-align: middle;
}
.table thead th,
.table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #747d8c;
    background: #f8f9fb !important;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .055em;
    text-transform: uppercase;
}
.table tbody tr:last-child td { border-bottom-width: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: #f8fafc; color: var(--text); }
.table-responsive { border-radius: var(--radius-sm); }

/* Badges */
.badge {
    border-radius: 999px;
    font-weight: 650;
    padding: .38rem .6rem;
    letter-spacing: .01em;
}
.text-bg-success { background: #e8f6ef !important; color: #25815a !important; }
.text-bg-danger { background: #fff0f0 !important; color: #ca4e4e !important; }
.text-bg-secondary { background: #eef1f4 !important; color: #657080 !important; }
.text-bg-info { background: #e9f3ff !important; color: #3375ce !important; }
.text-bg-light { background: #f4f5f7 !important; color: #566171 !important; border: 1px solid #e4e7ec; }

/* Alerts */
.alert {
    border-width: 1px;
    border-radius: var(--radius-md);
    font-size: 14px;
    padding: 13px 15px;
}
.alert-success { color: #216b4d; background: #edf8f3; border-color: #c9eadc; }
.alert-danger { color: #aa4242; background: #fff1f1; border-color: #f3cccc; }
.alert-warning { color: #8b641d; background: #fff8e8; border-color: #f0dfb6; }
.alert-info { color: #316b9f; background: #eef7ff; border-color: #cce5fb; }
.alert-light { background: #fafbfc; border-color: var(--border) !important; }

/* Accordion */
.accordion-item {
    background: #fff;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: none;
}
.accordion-button {
    color: var(--text-strong);
    background: #fff;
    font-weight: 600;
    box-shadow: none !important;
    padding: 15px 18px;
}
.accordion-button:not(.collapsed) { color: #2f6fd5; background: #f7faff; }
.accordion-button::after { opacity: .65; }
.accordion-body { border-top: 1px solid var(--border); }

/* Messages / utility surfaces */
.message-bubble {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .85rem 1rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.48;
}
.message-in { background: #f7f8fa; }
.message-out { background: #edf4ff; border-color: #d9e7fb; }
.code-chip {
    color: #596476;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .8rem;
}
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.bg-light { background-color: #f7f8fa !important; }
.border { border-color: var(--border) !important; }
.rounded { border-radius: var(--radius-sm) !important; }

/* Pagination */
.pagination { gap: 4px; }
.page-link {
    color: #526074;
    border-color: var(--border);
    border-radius: 7px !important;
    min-width: 36px;
    text-align: center;
}
.page-link:hover { color: #2f6fd5; background: var(--primary-soft); border-color: #c9dcfa; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-item.disabled .page-link { color: #adb3bc; background: #f7f8fa; }

/* Login */
.login-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(75,141,248,.10), transparent 34%),
        linear-gradient(135deg, #f7f9fc 0%, #f3f5f8 52%, #eef3fb 100%);
    display: flex;
    align-items: center;
}
.login-card {
    max-width: 440px;
    margin: auto;
    border: 1px solid var(--border) !important;
    border-radius: 14px;
    box-shadow: var(--shadow-float);
}
.login-card .text-primary { color: var(--primary) !important; }
.login-card h1 { font-weight: 700; letter-spacing: -.03em; }
.login-card .card-body { background: #fff; border-radius: 14px; }

/* Subtle polish */
.dropdown-menu {
    border-color: var(--border);
    border-radius: 9px;
    box-shadow: var(--shadow-float);
}
hr { border-color: var(--border); opacity: 1; }

.sidebar-overlay { display: none; }

@media (max-width: 1199.98px) {
    :root { --sidebar-width: 260px; }
    .portal-main > .container-fluid { padding-left: 26px !important; padding-right: 26px !important; }
}

@media (max-width: 991.98px) {
    :root { --sidebar-width: 280px; }
    .navbar.navbar-dark.bg-dark { padding: 0 14px; }
    .portal-sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        transition: left .2s ease;
        box-shadow: none;
    }
    .portal-sidebar.show { left: 0; box-shadow: .65rem 0 2rem rgba(22,28,45,.12); }
    .sidebar-overlay {
        position: fixed;
        inset: var(--topbar-height) 0 0 0;
        background: rgba(22,28,45,.28);
        backdrop-filter: blur(1px);
        z-index: 1020;
    }
    .sidebar-overlay.show { display: block; }
    .portal-main > .container-fluid { padding: 22px 20px 34px !important; }
    .table-scroll { max-height: calc(100vh - 235px); }
}

@media (max-width: 575.98px) {
    .navbar .navbar-brand { font-size: 16px; }
    .portal-main > .container-fluid { padding: 18px 14px 28px !important; }
    h1.h3, .h3 { font-size: 24px; }
    .card-header { padding: 13px 15px; }
    .section-card .card-body:not(.p-0), .metric-card .card-body { padding-left: 15px; padding-right: 15px; }
    .btn { min-height: 38px; }
    .login-shell { padding-left: 12px; padding-right: 12px; }
}
