/* ============================================================
   Academy Points System Pro — Frontend Dashboard
   Aesthetic: Premium dark-accent SaaS with emerald & indigo
   ============================================================ */

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

.aps-dashboard {
    --aps-primary:   #6366f1;
    --aps-secondary: #10b981;
    --aps-accent:    #f59e0b;
    --aps-danger:    #ef4444;
    --aps-bg:        #f5f7ff;
    --aps-card:      #ffffff;
    --aps-border:    #e8eaf6;
    --aps-text:      #1a1c2e;
    --aps-text2:     #4b5563;
    --aps-muted:     #9ca3af;
    --aps-radius:    16px;
    --aps-radius-sm: 10px;
    --aps-shadow:    0 4px 20px rgba(99,102,241,.08);
    --aps-shadow-lg: 0 12px 40px rgba(99,102,241,.16);

    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    color: var(--aps-text);
    background: var(--aps-bg);
    padding: 24px;
    border-radius: 20px;
    max-width: 900px;
    margin: 0 auto;
}

/* ── Header card ─────────────────────────────────────────────────── */
.aps-dash-header {
    background: linear-gradient(135deg, #312e81 0%, #4f46e5 50%, #7c3aed 100%);
    border-radius: var(--aps-radius);
    padding: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--aps-shadow-lg);
}
.aps-dash-header::before {
    content: "";
    position: absolute;
    top: -60px; right: -60px;
    width: 220px; height: 220px;
    background: rgba(255,255,255,.06);
    border-radius: 50%;
}
.aps-dash-header::after {
    content: "";
    position: absolute;
    bottom: -80px; left: 40%;
    width: 280px; height: 280px;
    background: rgba(255,255,255,.04);
    border-radius: 50%;
}

.aps-user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}
.aps-avatar {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    border: 3px solid rgba(255,255,255,.4) !important;
    object-fit: cover;
}
.aps-user-name {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 6px;
    line-height: 1.2;
}
.aps-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.aps-points-hero {
    text-align: right;
    position: relative;
    z-index: 1;
}
.aps-points-number {
    display: block;
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    letter-spacing: -2px;
}
.aps-points-label {
    font-size: 12px;
    color: rgba(255,255,255,.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.aps-card {
    background: var(--aps-card);
    border-radius: var(--aps-radius);
    box-shadow: var(--aps-shadow);
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid var(--aps-border);
    transition: box-shadow .25s;
}
.aps-card:hover { box-shadow: var(--aps-shadow-lg); }
.aps-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--aps-text);
    margin: 0 0 18px;
}

/* ── Level progress ──────────────────────────────────────────────── */
.aps-level-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.aps-level-icon { font-size: 32px; }
.aps-level-header strong {
    display: block;
    font-size: 16px;
    font-weight: 700;
}
.aps-level-next {
    font-size: 12px;
    color: var(--aps-text2);
    font-weight: 500;
}

.aps-progress-bar {
    background: #eef2ff;
    border-radius: 99px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}
.aps-progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--level-color, #6366f1), color-mix(in srgb, var(--level-color, #6366f1) 60%, #fff));
    transition: width .8s cubic-bezier(.4,0,.2,1);
    position: relative;
}
.aps-progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.35) 0%, transparent 100%);
    border-radius: inherit;
}
.aps-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--aps-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── Redeem form ─────────────────────────────────────────────────── */
.aps-redeem-card { background: linear-gradient(135deg, #fdfefe 0%, #f0fdf4 100%); }
.aps-redeem-form {
    display: flex;
    gap: 10px;
}
#aps-code-input {
    flex: 1;
    border: 2px solid var(--aps-border);
    border-radius: var(--aps-radius-sm);
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--aps-text);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
#aps-code-input:focus {
    border-color: var(--aps-secondary);
    box-shadow: 0 0 0 4px rgba(16,185,129,.12);
}
#aps-code-input::placeholder { color: var(--aps-muted); letter-spacing: .5px; font-weight: 500; }

.aps-btn {
    padding: 12px 24px;
    border-radius: var(--aps-radius-sm);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: transform .15s, box-shadow .15s, background .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.aps-btn:active { transform: scale(.97); }
.aps-btn-primary {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16,185,129,.35);
}
.aps-btn-primary:hover {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 6px 20px rgba(16,185,129,.45);
    transform: translateY(-1px);
}
.aps-btn-primary:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.aps-redeem-message {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: var(--aps-radius-sm);
    font-size: 14px;
    font-weight: 600;
    animation: apsFadeIn .3s ease;
}
.aps-redeem-message.aps-msg-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.aps-redeem-message.aps-msg-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }

@keyframes apsFadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── Badges ──────────────────────────────────────────────────────── */
.aps-badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}
.aps-badge-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px 10px;
    border-radius: var(--aps-radius-sm);
    border: 2px solid var(--aps-border);
    cursor: default;
    transition: transform .2s, box-shadow .2s;
    gap: 6px;
}
.aps-badge-item:hover { transform: translateY(-3px); box-shadow: var(--aps-shadow); }
.aps-badge-earned {
    background: linear-gradient(135deg, #fffbeb, #fef9c3);
    border-color: #f59e0b;
}
.aps-badge-locked { background: #f9fafb; opacity: .55; filter: grayscale(.5); }
.aps-badge-icon { font-size: 28px; line-height: 1; }
.aps-badge-name { font-size: 11px; font-weight: 700; color: var(--aps-text); line-height: 1.2; }
.aps-badge-lock { position: absolute; top: 6px; right: 6px; font-size: 10px; }

/* ── History table ───────────────────────────────────────────────── */
.aps-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.aps-history-table thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--aps-muted);
    background: #f8f9ff;
    border-bottom: 2px solid var(--aps-border);
}
.aps-history-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--aps-border);
    color: var(--aps-text);
    vertical-align: middle;
}
.aps-history-table tbody tr:last-child td { border-bottom: none; }
.aps-history-table tbody tr:hover td { background: #f8f9ff; }
.aps-pos { color: #059669; font-weight: 700; }
.aps-neg { color: #dc2626; font-weight: 700; }

/* ── Empty state ─────────────────────────────────────────────────── */
.aps-empty-state {
    text-align: center;
    padding: 40px;
    color: var(--aps-muted);
    font-size: 15px;
}

/* ── Login prompt ────────────────────────────────────────────────── */
.aps-login-prompt {
    text-align: center;
    padding: 48px;
    font-size: 16px;
    color: var(--aps-text2);
}
.aps-login-prompt a { color: var(--aps-primary); font-weight: 700; text-decoration: none; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .aps-dashboard { padding: 16px; }
    .aps-dash-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .aps-points-hero { text-align: left; }
    .aps-points-number { font-size: 40px; }
    .aps-redeem-form { flex-direction: column; }
    .aps-badges-grid { grid-template-columns: repeat(3, 1fr); }
}
