﻿/* ============================================================
   Online Membership System — Mobile-first stylesheet
   ============================================================ */

:root {
    --c-primary: #1e3a8a;
    --c-primary-dark: #172554;
    --c-primary-light: #3b82f6;
    --c-accent: #f59e0b;
    --c-bg: #f5f7fb;
    --c-card: #ffffff;
    --c-border: #e2e8f0;
    --c-text: #1f2937;
    --c-text-muted: #64748b;
    --c-success: #16a34a;
    --c-danger: #dc2626;
    --c-warning: #d97706;
    --c-info: #0891b2;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, .1), 0 8px 10px -6px rgba(15, 23, 42, .04);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--c-primary);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

h1, h2, h3, h4 {
    margin: 0 0 .6em;
    color: var(--c-primary-dark);
    font-weight: 600;
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.3rem;
}

h3 {
    font-size: 1.1rem;
}

small {
    color: var(--c-text-muted);
}

code {
    font-family: "Consolas", "SF Mono", "Menlo", "Ubuntu Mono", "Liberation Mono", monospace;
}

/* -------- Topbar / Nav -------- */
.topbar {
    background: var(--c-primary);
    color: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 60;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 56px;
    flex-wrap: wrap;
}

.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

    .brand:hover {
        text-decoration: none;
    }

.navtoggle {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 1.25rem;
    padding: 8px;
    cursor: pointer;
    display: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-link {
    color: #fff;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .9rem;
    transition: background .15s;
}

    .nav-link:hover {
        background: rgba(255,255,255,.12);
        text-decoration: none;
    }

    .nav-link i {
        font-size: .95rem;
    }

.nav-divider {
    width: 1px;
    background: rgba(255,255,255,.25);
    height: 22px;
    margin: 0 6px;
}

.nav-user {
    color: rgba(255,255,255,.95);
    font-size: .88rem;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .nav-user small {
        color: rgba(255,255,255,.7);
    }

.nav-backdrop {
    display: none;
}

@media (max-width: 760px) {
    .navtoggle {
        display: inline-flex;
    }

    .nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        background: var(--c-primary-dark);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 60px 12px 20px;
        gap: 2px;
        transform: translateX(100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
        z-index: 60;
        overflow-y: auto;
    }

        .nav.open {
            transform: translateX(0);
        }

    .nav-link {
        padding: 12px;
        border-radius: var(--radius-sm);
        font-size: .95rem;
    }

        .nav-link i {
            width: 18px;
            text-align: center;
        }

    .nav-divider {
        display: block;
        height: 1px;
        width: auto;
        background: rgba(255,255,255,.15);
        margin: 6px 4px;
    }

    .nav-user {
        padding: 10px 12px;
        font-size: .92rem;
    }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 55;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

        .nav-backdrop.show {
            opacity: 1;
            pointer-events: auto;
        }

    .navtoggle {
        position: relative;
        z-index: 70;
    }

    body.nav-open {
        overflow: hidden;
    }
}

/* -------- Container -------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px 60px;
    min-height: calc(100vh - 150px);
}

/* -------- Card -------- */
.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
}

.card-title {
    margin: 0 0 14px;
    font-size: 1.15rem;
    color: var(--c-primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 10px;
}

/* -------- Forms -------- */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .form-group label {
        font-size: .85rem;
        font-weight: 600;
        color: var(--c-text);
    }

    .form-group .req {
        color: var(--c-danger);
    }

.form-control {
    width: 100%;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    font-size: .95rem;
    background: #fff;
    color: var(--c-text);
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}

    .form-control:focus {
        outline: none;
        border-color: var(--c-primary-light);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
    }

    .form-control[readonly] {
        background: #f1f5f9;
        color: var(--c-text-muted);
    }

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

select.form-control {
    background: #fff;
}

/* -------- Buttons -------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .92rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: all .15s;
    background: #fff;
    color: var(--c-text);
    border-color: var(--c-border);
    white-space: nowrap;
}

    .btn:hover {
        text-decoration: none;
    }

    .btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.btn-primary {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
}

    .btn-primary:hover {
        background: var(--c-primary-dark);
        border-color: var(--c-primary-dark);
    }

.btn-success {
    background: var(--c-success);
    color: #fff;
    border-color: var(--c-success);
}

    .btn-success:hover {
        filter: brightness(.92);
    }

.btn-danger {
    background: var(--c-danger);
    color: #fff;
    border-color: var(--c-danger);
}

    .btn-danger:hover {
        filter: brightness(.92);
    }

.btn-warning {
    background: var(--c-warning);
    color: #fff;
    border-color: var(--c-warning);
}

    .btn-warning:hover {
        filter: brightness(.92);
    }

.btn-info {
    background: var(--c-info);
    color: #fff;
    border-color: var(--c-info);
}

    .btn-info:hover {
        filter: brightness(.92);
    }

.btn-light {
    background: #f1f5f9;
    color: var(--c-text);
    border-color: var(--c-border);
}

    .btn-light:hover {
        background: #e2e8f0;
    }

.btn-sm {
    padding: 5px 10px;
    font-size: .82rem;
}

.btn-block {
    width: 100%;
}

.btn-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

/* -------- Tables -------- */
.table-wrap {
    overflow-x: auto;
    margin: 0 -4px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

    .table th, .table td {
        padding: 10px 12px;
        text-align: left;
        border-bottom: 1px solid var(--c-border);
        vertical-align: middle;
    }

    .table th {
        background: #f1f5f9;
        color: var(--c-text);
        font-weight: 600;
        position: sticky;
        top: 0;
        font-size: .82rem;
        text-transform: uppercase;
        letter-spacing: .03em;
    }

    .table tbody tr:hover {
        background: #f8fafc;
    }

    .table .actions {
        display: flex;
        gap: 4px;
        flex-wrap: wrap;
    }

/* Responsive table: stack cells as blocks on mobile (opt-in via .table-responsive) */
@media (max-width: 768px) {
    .table-responsive thead {
        display: none;
    }

    .table-responsive,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive td {
        display: block;
        width: 100%;
    }

        .table-responsive tr {
            border-bottom: 1px solid var(--c-border);
            padding-bottom: 10px;
        }

        .table-responsive td {
            border-bottom: 0;
            padding: 3px 0;
            word-break: break-word;
        }

        .table-responsive tbody tr td:nth-child(2) {
            font-weight: bold;
        }

        .table-responsive td code {
            display: block;
            background: #becce1;
            color: #172554;
            padding: 5px 10px;
            border-radius: 6px;
            font-size: 12pt;
        }
}

/* -------- Badges -------- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    line-height: 1.4;
}

.badge-success {
    background: #dcfce7;
    color: #14532d;
}

.badge-danger {
    background: #fee2e2;
    color: #7f1d1d;
}

.badge-warning {
    background: #fef3c7;
    color: #78350f;
}

.badge-info {
    background: #cffafe;
    color: #155e75;
}

.badge-secondary {
    background: #e2e8f0;
    color: #1f2937;
}

/* -------- Alerts -------- */
.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    border: 1px solid;
    margin-bottom: 14px;
    font-size: .9rem;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
}

.alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #7f1d1d;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #78350f;
}

.alert-info {
    background: #ecfeff;
    border-color: #a5f3fc;
    color: #155e75;
}

/* -------- Stats / Dashboard -------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-body {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--c-text-muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--c-primary-dark);
}

.stat-primary .stat-icon {
    background: var(--c-primary);
}

.stat-success .stat-icon {
    background: var(--c-success);
}

.stat-warning .stat-icon {
    background: var(--c-warning);
}

.stat-danger .stat-icon {
    background: var(--c-danger);
}

.stat-info .stat-icon {
    background: var(--c-info);
}

/* -------- Auth pages (login/register) -------- */
.auth-wrap {
    max-width: 460px;
    margin: 30px auto;
}

.auth-card {
    background: var(--c-card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--c-border);
}

    .auth-card h2 {
        text-align: center;
        margin-bottom: 4px;
        font-size: 1.4rem;
    }

    .auth-card .lead {
        text-align: center;
        color: var(--c-text-muted);
        margin-bottom: 22px;
        font-size: .9rem;
    }

/* -------- Footer -------- */
.footer {
    background: #fff;
    border-top: 1px solid var(--c-border);
    margin-top: 30px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    text-align: center;
    color: var(--c-text-muted);
}

/* -------- Toast -------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: calc(100vw - 40px);
}

.toast {
    background: #1f2937;
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
    min-width: 220px;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 9px;
    animation: toastIn .2s ease-out;
}

    .toast.success {
        background: var(--c-success);
    }

    .toast.error {
        background: var(--c-danger);
    }

    .toast.warning {
        background: var(--c-warning);
    }

    .toast.info {
        background: var(--c-info);
    }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* -------- Utility -------- */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-1 {
    margin-bottom: 4px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--c-text-muted);
}

.text-primary {
    color: var(--c-primary);
}

.text-danger {
    color: var(--c-danger);
}

.text-success {
    color: var(--c-success);
}

.text-warning {
    color: var(--c-warning);
}

.hidden {
    display: none !important;
}

.w-100 {
    width: 100%;
}

/* -------- Profile view -------- */
.profile-header {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 0 18px;
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 18px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-meta h3 {
    margin: 0 0 4px;
    font-size: 1.3rem;
}

.profile-meta .meta-line {
    color: var(--c-text-muted);
    font-size: .9rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: .75rem;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.detail-value {
    font-size: .98rem;
    color: var(--c-text);
    padding: 3px 0;
    word-break: break-word;
}

/* -------- Print -------- */
@media print {
    .topbar, .footer, .btn-bar, .no-print {
        display: none !important;
    }

    .container {
        padding: 0;
        max-width: 100%;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: #fff;
    }
}

/* -------- Search bar -------- */
.search-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
    align-items: end;
}

/* -------- Pagination -------- */
.pager {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 14px;
    flex-wrap: wrap;
}

    .pager .btn {
        min-width: 36px;
        padding: 5px 9px;
        font-size: .85rem;
    }

    .pager .active {
        background: var(--c-primary);
        color: #fff;
        border-color: var(--c-primary);
    }
