/* LeadPortal — responsive, readable UI */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #172033;
    --sidebar-surface: #202b40;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #8fa0b8;
    --brand-blue: #4f8cff;
    --page-bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #dfe6ef;
    --text: #172033;
    --muted: #617089;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --warning: #b45309;
    --danger: #dc2626;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 14px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
    overflow-x: hidden;
}

a {
    text-underline-offset: 2px;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* --------------------------------------------------------------------------
   App shell + sidebar
   -------------------------------------------------------------------------- */
.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 22px 14px 18px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--sidebar-bg);
    color: #fff;
    box-shadow: 8px 0 30px rgba(15, 23, 42, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.sidebar-brand-row {
    display: flex;
    align-items: center;
    min-height: 44px;
}

.brand {
    display: block;
    flex: 1;
    padding: 0 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand span {
    color: var(--brand-blue);
}

.sidebar-close {
    flex: 0 0 auto;
    margin-left: 8px;
    margin-bottom: 18px;
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 22px;
    line-height: 1;
}

.sidebar-close:hover,
.sidebar-close:focus-visible {
    background: rgba(255, 255, 255, 0.16);
}

.user-mini {
    margin: 16px 0 12px;
    padding: 12px 12px 14px;
    color: #fff;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.055);
}

.user-mini-name {
    display: block;
    font-weight: 650;
    color: #fff;
}

.user-mini small {
    display: block;
    margin-top: 3px;
    color: var(--sidebar-muted);
    font-size: 12px;
}

.sidebar .nav {
    gap: 4px !important;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 550;
    text-decoration: none;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus-visible {
    color: #fff;
    background: var(--sidebar-surface);
    transform: translateX(2px);
}

.sidebar .nav-link.active {
    color: #fff;
    background: #334155;
    box-shadow: inset 3px 0 0 var(--brand-blue);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
}

.sidebar-footer .btn {
    border-color: rgba(255, 255, 255, 0.2);
    color: #e5e7eb;
}

.sidebar-footer .btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.35);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.main-content {
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    margin-left: var(--sidebar-width);
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 70px;
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.topbar-title {
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
}

.topbar-date {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.mobile-menu-button {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 20px;
    line-height: 1;
}

.mobile-menu-button:hover,
.mobile-menu-button:focus-visible {
    border-color: #b9c7dc;
    background: var(--surface-muted);
}

/* --------------------------------------------------------------------------
   Content + common components
   -------------------------------------------------------------------------- */
.page-content {
    min-width: 0;
    padding-top: 30px !important;
    padding-bottom: 40px !important;
}

.page-heading h1,
.page-heading h2,
.page-heading h3,
.page-heading h4,
.page-heading h5,
.page-heading h6 {
    color: var(--text);
    letter-spacing: -0.3px;
}

.page-heading p,
.text-secondary {
    color: var(--muted) !important;
}

.stat-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card {
    height: 100%;
    padding: 20px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.stat-value {
    margin-top: 5px;
    color: var(--text);
    font-size: 30px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.8px;
}

.panel {
    overflow: hidden;
}

.panel-title {
    color: var(--text);
    font-weight: 750;
}

.campaign-card {
    height: 100%;
    padding: 22px;
}

.campaign-header {
    min-width: 0;
}

.campaign-header > * {
    min-width: 0;
}

.campaign-link {
    max-width: 100%;
    padding: 11px 12px;
    border: 1px solid #e3e9f2;
    border-radius: 9px;
    background: #f7f9fc;
    color: #34445d;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.link-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.badge {
    font-weight: 650;
    letter-spacing: 0.1px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table,
.table-wrap > .table {
    min-width: 720px;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 14px 12px;
    vertical-align: middle;
    border-color: #edf1f6;
}

.table thead th {
    color: #53627a;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody td {
    color: #26364f;
    font-size: 14px;
}

.table tbody tr:hover td {
    background: #fbfcfe;
}

.table td,
.table th,
code,
.text-break {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.form-label {
    color: #334155;
    font-size: 14px;
    font-weight: 650;
}

.form-control,
.form-select {
    min-height: 44px;
    border-color: #ccd6e4;
    color: var(--text);
    background-color: #fff;
}

.form-control::placeholder {
    color: #8794a8;
}

.form-control:focus,
.form-select:focus {
    border-color: #6f9cf6;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
}

.btn {
    font-weight: 650;
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
}

.action-row {
    margin-bottom: 18px;
}

.alert {
    border-radius: 12px;
}

hr {
    border-color: var(--border);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Authentication + public pages
   -------------------------------------------------------------------------- */
.login-wrap,
.public-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background: radial-gradient(circle at top left, #e9f1ff 0, transparent 38%), var(--page-bg);
}

.login-card,
.public-card {
    width: min(520px, 100%);
    padding: 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
}

.login-card {
    width: min(440px, 100%);
}

.auth-logo {
    font-size: 30px;
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: -1px;
}

.auth-logo span {
    color: var(--brand-blue);
}

code {
    color: #475569;
    font-size: 0.875em;
}

.btn-group {
    max-width: 100%;
}

.btn-group > .btn {
    min-width: 0;
    white-space: normal;
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: min(290px, 88vw);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-105%);
        box-shadow: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 12px 0 40px rgba(15, 23, 42, 0.22);
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        min-height: 64px;
        padding: 10px 16px;
    }

    .page-content {
        padding-top: 24px !important;
        padding-bottom: 30px !important;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding: 9px 12px;
    }

    .topbar-date {
        display: none;
    }

    .page-content {
        padding-right: 12px !important;
        padding-left: 12px !important;
    }

    .login-wrap,
    .public-wrap {
        place-items: start center;
        padding: 8vh 12px 24px;
    }

    .login-card,
    .public-card {
        padding: 22px 18px;
        border-radius: 14px;
    }

    .campaign-card {
        padding: 18px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 26px;
    }

    .panel.p-4 {
        padding: 18px !important;
    }

    .panel.p-3 {
        padding: 14px !important;
    }

    .action-row {
        align-items: stretch !important;
    }

    .action-row > * {
        width: 100%;
    }

    .action-row .btn {
        width: 100%;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .btn-group > .btn {
        width: 100%;
        border-radius: 0.5rem !important;
    }

    .input-group {
        flex-wrap: wrap;
        gap: 8px;
    }

    .input-group > .form-control,
    .input-group > .form-select,
    .input-group > .btn {
        width: 100%;
        border-radius: 0.5rem !important;
    }

    .input-group > .btn {
        margin-top: 0;
    }
}

@media (min-width: 992px) {
    .sidebar-close,
    .sidebar-backdrop,
    .mobile-menu-button {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Laravel pagination readability */
.pagination {
    flex-wrap: wrap;
    gap: 4px;
}

.pagination .page-link {
    border-radius: 8px !important;
    border-color: var(--border);
    color: #334155;
    margin: 0 !important;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #9aa6b8;
    background: #f8fafc;
}
