@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #003399;
    --primary-dark: #002266;
    --accent: #FFCC00;
    --success: #21b573;
    --danger: #ef4a63;
    --bg: #f4f6fb;
    --card-radius: 16px;
    --sidebar-w: 260px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: #1f2333;
    margin: 0;
}

a {
    text-decoration: none;
}

/* ---------- App layout (member & admin panels) ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-brand img {
    height: 32px;
}

.sidebar-brand span {
    font-weight: 800;
    font-size: .95rem;
    line-height: 1.2;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, .8);
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 500;
    font-size: .9rem;
    margin-bottom: 4px;
    transition: all .15s;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--accent);
    color: var(--primary-dark);
    font-weight: 700;
}

.sidebar-foot {
    padding: 14px 20px;
    font-size: .72rem;
    color: rgba(255, 255, 255, .5);
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 66px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 10px rgba(0, 20, 60, .05);
}

.topbar .burger {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #444;
}

.topbar .user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.topbar .user-chip img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.page-wrap {
    padding: 24px;
    max-width: 1140px;
    width: 100%;
    margin: 0 auto;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-area {
        margin-left: 0;
    }

    .topbar .burger {
        display: inline-block;
    }
}

/* ---------- Components ---------- */
.card-x {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: 0 6px 20px rgba(0, 20, 60, .06);
    padding: 22px;
}

.stat-card {
    border-radius: var(--card-radius);
    padding: 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #2255cc);
    box-shadow: 0 8px 20px rgba(0, 51, 153, .25);
}

.stat-card.gold {
    background: linear-gradient(135deg, #d19f00, var(--accent));
    color: #3a2c00;
    box-shadow: 0 8px 20px rgba(255, 204, 0, .3);
}

.stat-card.green {
    background: linear-gradient(135deg, #21b573, #4ed99a);
}

.stat-card .stat-label {
    font-size: .78rem;
    opacity: .9;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 4px;
}

.btn-x {
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: .88rem;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-x-primary {
    background: var(--primary);
    color: #fff;
}

.btn-x-primary:hover {
    background: var(--primary-dark);
}

.btn-x-outline {
    background: #fff;
    border: 1.5px solid #dde1ec;
    color: #333;
}

.btn-x-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-x-danger {
    background: #fdeaec;
    color: var(--danger);
}

.btn-x-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-x-sm {
    padding: 6px 13px;
    font-size: .8rem;
}

.badge-x {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}

.badge-warning {
    background: #fff3d6;
    color: #b17a00;
}

.badge-success {
    background: #dcf7ea;
    color: #158a54;
}

.badge-danger {
    background: #fdeaec;
    color: #c62842;
}

.badge-muted {
    background: #eef0f6;
    color: #666;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.page-sub {
    color: #767a8c;
    font-size: .9rem;
    margin-bottom: 22px;
}

.form-x label {
    font-weight: 600;
    font-size: .84rem;
    margin-bottom: 5px;
    display: block;
}

.form-x .form-control,
.form-x select,
.form-x textarea {
    border-radius: 10px;
    border: 1.5px solid #e0e3ee;
    padding: 10px 13px;
    width: 100%;
    font-family: inherit;
    font-size: .9rem;
}

.form-x .form-control:focus,
.form-x select:focus,
.form-x textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 51, 153, .1);
}

/* ---------- Auth pages ---------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #002266, #000f33 65%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 34px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.login-card img {
    height: 44px;
    margin-bottom: 10px;
}

/* ---------- Community feed ---------- */
.feed-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.feed-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-bubble {
    background: #f2f4fa;
    border-radius: 14px;
    padding: 8px 14px;
    max-width: 85%;
}

.feed-image {
    max-width: 100%;
    border-radius: 12px;
    max-height: 420px;
    object-fit: cover;
}

/* ---------- Member card ---------- */
.member-card {
    position: relative;
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1020 / 315;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(0, 20, 60, .22);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    /* Container query: font sizes now relative to card width, not browser width */
    container-type: inline-size;
    container-name: membercard;
}

.member-card-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.member-card-overlay {
    position: absolute;
    inset: 0;
}

.member-card-photo {
    position: absolute;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
    background: #fff;
    z-index: 2;
}

.member-card-data {
    position: absolute;
    color: #fff;
    z-index: 2;
}

/* Font mengikuti lebar KARTU (cqw), bukan lebar browser (vw) */
@container membercard (min-width: 1px) {
    .member-card-data .name {
        font-weight: 800;
        font-size: clamp(.45rem, 3.2cqw, .78rem);
        margin-bottom: 2px;
        line-height: 1.2;
        /* Potong otomatis jika nama sangat panjang */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .member-card-data .line {
        font-size: clamp(.35rem, 2.1cqw, .56rem);
        line-height: 1.45;
        opacity: .95;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Fallback untuk browser lama yang belum support container queries */
@supports not (container-type: inline-size) {
    .member-card-data .name {
        font-weight: 800;
        font-size: clamp(.45rem, 2.2cqw, .78rem);
        margin-bottom: 2px;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .member-card-data .line {
        font-size: clamp(.35rem, 1.4vw, .56rem);
        line-height: 1.45;
        opacity: .95;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media print {

    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .main-area {
        margin-left: 0 !important;
    }

    /* Fix: browsers skip CSS background-colors/gradients when printing
       unless explicitly told to keep them (this is what made the card
       print/PDF as a blank white box - the gradient background and any
       custom background image were simply not being painted). */
    .member-card,
    .member-card * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Also disable the responsive container-query sizing during print,
       since it can behave inconsistently in the print rendering context. */
    .member-card {
        container-type: normal !important;
    }

    .member-card-data .name {
        font-size: .78rem !important;
    }

    .member-card-data .line {
        font-size: .56rem !important;
    }
}

.table-x {
    width: 100%;
    border-collapse: collapse;
}

.table-x th {
    text-align: left;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8a8da3;
    padding: 10px 12px;
    border-bottom: 1.5px solid #eef0f6;
}

.table-x td {
    padding: 12px;
    border-bottom: 1px solid #f2f3f8;
    font-size: .88rem;
    vertical-align: middle;
}

.table-x tr:hover td {
    background: #fafbfe;
}
