/* ── Rendeu Dashboard — Custom Styles ─────────────────────────────────────── */

:root {
    --navy: #0b2414;
    --coral: #54c80f;
    --coral-light: #7cda3c;
    --sidebar-width: 240px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #34423a;
    --sidebar-active: #eaf7df;
    --top-navbar-height: 56px;
    --rendeu-border: #dde8d8;
    --rendeu-soft: #f7faf5;
    --rendeu-muted: #637067;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--rendeu-soft);
    color: #112119;
    overflow-x: hidden;
}

.text-navy { color: var(--navy) !important; }
.text-coral { color: var(--coral) !important; }

#wrapper,
#content-wrapper,
.main-content {
    min-width: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--rendeu-border);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-brand {
    text-decoration: none;
    padding: 0 1rem;
}

.sidebar-link {
    color: var(--sidebar-text);
    border-radius: 10px;
    padding: 0.7rem 0.95rem;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar-link:hover {
    background: #f1f7ec;
    color: var(--navy);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--navy);
    font-weight: 600;
}

#content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-navbar {
    background: #fff;
    border-bottom: 1px solid var(--rendeu-border);
    height: var(--top-navbar-height);
    position: sticky;
    top: 0;
    z-index: 1030;
    min-width: 0;
}

.top-navbar-title,
.top-navbar-email {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-navbar-title {
    flex: 1 1 auto;
}

.top-navbar-actions {
    min-width: 0;
    flex: 0 1 auto;
}

.main-content {
    padding: 1.5rem 2rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-coral {
    background-color: var(--coral);
    border-color: var(--coral);
    color: #fff;
    font-weight: 600;
}
.btn-coral:hover, .btn-coral:focus {
    background-color: var(--coral-light);
    border-color: var(--coral-light);
    color: #fff;
}
.btn-coral:active {
    background-color: #43a708;
    border-color: #43a708;
    color: #fff;
}
.btn-outline-coral {
    color: var(--coral);
    border-color: var(--coral);
    font-weight: 600;
}
.btn-outline-coral:hover {
    background-color: var(--coral);
    color: #fff;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge-coral {
    background-color: var(--coral);
    color: #fff;
}

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid var(--rendeu-border);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 10px 30px rgba(21, 42, 20, 0.04);
    position: relative;
    overflow: hidden;
    min-height: 118px;
}
.stat-card .stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.1;
    overflow-wrap: anywhere;
    padding-right: 2rem;
}
.stat-card .stat-icon {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    font-size: 1.5rem;
    opacity: 0.8;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--rendeu-border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(21, 42, 20, 0.04);
}
.card-header {
    border-radius: 14px 14px 0 0 !important;
    padding: 1rem 1.25rem 0.5rem;
    gap: 0.75rem;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
    min-width: 640px;
}

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

/* ── Password Display Modal ──────────────────────────────────────────────── */
.swal2-password-display {
    font-family: 'Courier New', monospace;
    font-size: 1.6rem;
    font-weight: bold;
    letter-spacing: 0.25em;
    background: #f4f6fb;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    display: inline-block;
    color: var(--navy);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .table-responsive,
    .dataTables_wrapper {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .table-responsive > .table,
    .dataTables_wrapper table.dataTable,
    .card-body > table.table {
        min-width: 640px;
    }
    .card-body > table.table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        max-width: 84vw;
    }
    #content-wrapper {
        margin-left: 0;
    }
    #wrapper.sidebar-toggled #sidebar {
        margin-left: 0;
    }
    #wrapper.sidebar-toggled .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1035;
        background: rgba(13, 27, 42, 0.45);
    }
    .top-navbar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    .top-navbar-email {
        display: none;
    }
    .main-content,
    .main-content.p-4 {
        padding: 1rem !important;
    }
    .card-header {
        align-items: flex-start !important;
        flex-wrap: wrap;
    }
    .card-header .btn,
    .card-header .btn-group {
        flex-shrink: 0;
    }
    .stat-card {
        padding: 1rem;
        min-height: 104px;
    }
    .stat-card .stat-value {
        font-size: 1.45rem;
        padding-right: 1.75rem;
    }
    .stat-card .stat-icon {
        top: 0.85rem;
        right: 1rem;
        font-size: 1.25rem;
    }
}

/* ── Central dashboard modern layout ─────────────────────────────────────── */
.dashboard-modern {
    color: var(--navy);
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.6rem;
}

.dashboard-eyebrow {
    margin: 0 0 0.25rem;
    color: var(--coral);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-hero h1 {
    margin: 0;
    color: var(--navy);
    font-size: clamp(1.55rem, 2.5vw, 2.15rem);
    font-weight: 800;
    letter-spacing: 0;
}

.dashboard-hero span {
    color: var(--rendeu-muted);
    font-size: 0.95rem;
}

.dashboard-date-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 44px;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--rendeu-border);
    border-radius: 12px;
    background: #fff;
    color: #1e2b23;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(21, 42, 20, 0.04);
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
}

.dashboard-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-grid-main {
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
}

.dashboard-card {
    background: #fff;
    border: 1px solid var(--rendeu-border);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 12px 34px rgba(21, 42, 20, 0.045);
    min-width: 0;
}

.dashboard-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.dashboard-card-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--navy);
}

.dashboard-card-head p {
    margin: 0.2rem 0 0;
    color: var(--rendeu-muted);
    font-size: 0.84rem;
}

.dashboard-select {
    border-color: var(--rendeu-border);
    border-radius: 10px;
    font-weight: 600;
}

.dashboard-metric {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 112px;
}

.metric-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e8f8dc, #f4fbef);
    color: var(--navy);
    font-size: 1.35rem;
}

.dashboard-metric small,
.dashboard-mini-stat small {
    display: block;
    margin-bottom: 0.25rem;
    color: #435148;
    font-size: 0.86rem;
    font-weight: 600;
}

.dashboard-metric strong,
.dashboard-mini-stat strong {
    display: block;
    color: var(--navy);
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.dashboard-metric em {
    display: block;
    margin-top: 0.3rem;
    color: #229600;
    font-size: 0.82rem;
    font-style: normal;
    font-weight: 700;
}

.dashboard-chart-card {
    min-height: 310px;
}

.dashboard-chart-value {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.dashboard-chart-value strong {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--navy);
}

.dashboard-chart-value span {
    color: var(--rendeu-muted);
    font-size: 0.9rem;
}

.dashboard-chart-wrap {
    min-height: 190px;
}

.dashboard-bars-card {
    min-height: 310px;
}

.retention-bars {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 0.8rem;
    min-height: 210px;
    padding-top: 1rem;
}

.retention-bar-item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}

.retention-bar-track {
    display: flex;
    align-items: end;
    width: 28px;
    height: 150px;
    border-radius: 999px;
    background: #edf2e8;
    overflow: hidden;
}

.retention-bar-track span {
    display: block;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--coral), #8dde57);
}

.retention-bar-item small {
    color: #445249;
    font-size: 0.75rem;
    font-weight: 700;
}

.platform-split {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.platform-donut {
    width: 132px;
    aspect-ratio: 1;
    flex: 0 0 132px;
    border-radius: 50%;
    background: conic-gradient(var(--coral) 0 var(--machine-pct), #cfeab7 var(--machine-pct) 100%);
    position: relative;
}

.platform-donut::after {
    content: "";
    position: absolute;
    inset: 28px;
    border-radius: 50%;
    background: #fff;
}

.platform-legend {
    display: grid;
    gap: 0.7rem;
    width: 100%;
}

.platform-legend div,
.risk-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: #2d3b32;
    font-size: 0.92rem;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 0.45rem;
    border-radius: 50%;
}

.legend-machine { background: var(--coral); }
.legend-external { background: #cfeab7; }
.legend-soft { background: #ecf3e8; }

.dashboard-soft-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: #eef8e8;
    color: var(--navy);
    font-weight: 800;
    text-decoration: none;
}

.dashboard-soft-link:hover {
    background: #e2f4d4;
    color: var(--navy);
}

.subscription-summary {
    display: grid;
    gap: 0.65rem;
}

.subscription-summary strong,
.risk-score strong {
    color: var(--navy);
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.1;
}

.subscription-summary span,
.risk-score span {
    color: var(--rendeu-muted);
    font-size: 0.9rem;
}

.dashboard-progress {
    height: 7px;
    border-radius: 999px;
    background: #e8eee3;
}

.dashboard-progress .progress-bar {
    background: var(--coral);
}

.risk-score {
    display: grid;
    gap: 0.2rem;
    margin-bottom: 1rem;
}

.risk-list {
    display: grid;
    gap: 0.7rem;
    min-height: 86px;
}

.risk-list strong {
    color: #229600;
}

.dashboard-mini-stat {
    min-height: 108px;
}

.dashboard-table-card {
    padding: 0;
    overflow: hidden;
}

.dashboard-table-card .dashboard-card-head {
    padding: 1.25rem 1.25rem 0;
}

.dashboard-table-card .table {
    margin-top: 0.35rem;
}

.dashboard-table-card thead {
    background: #f6faf2;
}

@media (max-width: 1199.98px) {
    .dashboard-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dashboard-grid-main,
    .dashboard-grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }
    .dashboard-date-pill {
        width: 100%;
        justify-content: space-between;
    }
    .dashboard-grid-4 {
        grid-template-columns: 1fr;
    }
    .dashboard-card {
        padding: 1rem;
        border-radius: 14px;
    }
    .dashboard-card-head {
        flex-wrap: wrap;
    }
    .dashboard-chart-value {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.2rem;
    }
    .platform-split {
        align-items: flex-start;
        flex-direction: column;
    }
    .retention-bars {
        min-height: 170px;
    }
    .retention-bar-track {
        width: 22px;
        height: 120px;
    }
}

@media (max-width: 575.98px) {
    h4 {
        font-size: 1.15rem;
    }
    .top-navbar-title {
        font-size: 0.92rem;
    }
    .main-content,
    .main-content.p-4 {
        padding: 0.75rem !important;
    }
    .card-body {
        padding: 1rem;
    }
    .card-body.p-0 {
        padding: 0 !important;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 {
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .dataTables_wrapper .row {
        gap: 0.75rem;
    }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: left !important;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0;
        margin-top: 0.35rem;
    }
}

/* ── DataTables overrides ─────────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    padding: 0.35rem 0.75rem;
}
.dataTables_wrapper .dataTables_length select {
    border-radius: 6px;
    border: 1px solid #dee2e6;
}
