/* ========================================
   Next Action Widget + Visual Learning Path
   ======================================== */

/* --- Next Action Floating Widget --- */
.cx-next-action {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    direction: rtl;
    font-family: 'Tajawal', sans-serif;
}

/* Toggle button */
.cx-na-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(99,102,241,0.4);
    background: linear-gradient(135deg, rgba(99,102,241,0.9), rgba(6,182,212,0.9));
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(99,102,241,0.35);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
.cx-na-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(99,102,241,0.5);
}
.cx-na-toggle.active {
    background: rgba(30,41,59,0.95);
    border-color: rgba(99,102,241,0.5);
}

/* Pulse dot on toggle */
.cx-na-toggle .cx-na-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid rgba(30,41,59,0.9);
    animation: cxNaDotPulse 2s infinite;
}
@keyframes cxNaDotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Panel */
.cx-na-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-height: 520px;
    overflow-y: auto;
    border-radius: 20px;
    background: rgba(15,23,42,0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(99,102,241,0.2);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cx-na-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Panel header */
.cx-na-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cx-na-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cx-na-header h3 i {
    color: var(--primary-light, #818cf8);
}
.cx-na-streak {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(239,68,68,0.2));
    color: #f59e0b;
    font-weight: 600;
}

/* Next action card */
.cx-na-card {
    margin: 14px 16px;
    padding: 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(6,182,212,0.08));
    border: 1px solid rgba(99,102,241,0.2);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: block;
    color: inherit;
}
.cx-na-card:hover {
    border-color: rgba(99,102,241,0.4);
    background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(6,182,212,0.12));
    transform: translateX(-3px);
}
.cx-na-card-label {
    font-size: 0.75rem;
    color: var(--primary-light, #818cf8);
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cx-na-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}
.cx-na-card-desc {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.6);
    line-height: 1.4;
}
.cx-na-card-arrow {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--primary-light, #818cf8);
    font-weight: 600;
}
.cx-na-card-arrow i {
    margin-right: 4px;
    transition: margin-right 0.2s;
}
.cx-na-card:hover .cx-na-card-arrow i {
    margin-right: 8px;
}

/* Quick stats */
.cx-na-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 16px 14px;
}
.cx-na-stat {
    text-align: center;
    padding: 10px 4px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}
.cx-na-stat-num {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.cx-na-stat-label {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
}

/* --- Visual Learning Path (inside panel) --- */
.cx-na-path {
    padding: 0 16px 16px;
}
.cx-na-path-title {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 10px;
    font-weight: 600;
}
.cx-na-path-track {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
}
.cx-na-path-node {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    text-decoration: none;
    color: inherit;
}
.cx-na-path-node:hover {
    transform: scale(1.25);
    z-index: 2;
}

/* Node states */
.cx-na-path-node.completed {
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}
.cx-na-path-node.current {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    box-shadow: 0 2px 12px rgba(99,102,241,0.4);
    animation: cxPathNodePulse 2s infinite;
}
.cx-na-path-node.locked {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.08);
}
.cx-na-path-node.has-quiz {
    border: 2px solid rgba(245,158,11,0.5);
}
@keyframes cxPathNodePulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(99,102,241,0.4); }
    50% { box-shadow: 0 2px 20px rgba(99,102,241,0.6); }
}

/* Connector line */
.cx-na-path-line {
    width: 8px;
    height: 2px;
    border-radius: 1px;
    flex-shrink: 0;
}
.cx-na-path-line.done {
    background: linear-gradient(90deg, #10b981, #06b6d4);
}
.cx-na-path-line.pending {
    background: rgba(255,255,255,0.08);
}

/* Trophy at end */
.cx-na-path-trophy {
    font-size: 1.1rem;
    margin-right: 4px;
}

/* Tooltip for path nodes */
.cx-na-path-node[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(0,0,0,0.9);
    color: #fff;
    font-size: 0.65rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

/* Suggested tools section */
.cx-na-tools {
    padding: 0 16px 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: 4px;
    padding-top: 12px;
}
.cx-na-tools-title {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 8px;
    font-weight: 600;
}
.cx-na-tool-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.82rem;
    transition: all 0.2s;
    margin-bottom: 4px;
}
.cx-na-tool-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.cx-na-tool-link i {
    color: var(--primary-light, #818cf8);
    width: 16px;
    text-align: center;
}
.cx-na-tool-link .done-check {
    color: #10b981;
    margin-right: auto;
    font-size: 0.7rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .cx-na-panel {
        width: calc(100vw - 32px);
        right: -8px;
        max-height: 70vh;
    }
    .cx-na-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }
    .cx-next-action {
        bottom: 16px;
        right: 16px;
    }
}

/* --- Light Theme --- */
body.light-theme .cx-na-panel {
    background: rgba(248,250,252,0.97);
    border-color: rgba(99,102,241,0.15);
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}
body.light-theme .cx-na-header h3 {
    color: #1e293b;
}
body.light-theme .cx-na-card {
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(6,182,212,0.04));
    border-color: rgba(99,102,241,0.12);
}
body.light-theme .cx-na-card:hover {
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.06));
}
body.light-theme .cx-na-card-title {
    color: #1e293b;
}
body.light-theme .cx-na-card-desc {
    color: #64748b;
}
body.light-theme .cx-na-stat {
    background: rgba(0,0,0,0.02);
    border-color: rgba(0,0,0,0.05);
}
body.light-theme .cx-na-stat-label {
    color: #94a3b8;
}
body.light-theme .cx-na-path-node.locked {
    background: rgba(0,0,0,0.04);
    color: rgba(0,0,0,0.25);
    border-color: rgba(0,0,0,0.08);
}
body.light-theme .cx-na-tool-link {
    color: #475569;
}
body.light-theme .cx-na-tool-link:hover {
    background: rgba(0,0,0,0.03);
    color: #1e293b;
}
body.light-theme .cx-na-toggle.active {
    background: rgba(248,250,252,0.95);
    border-color: rgba(99,102,241,0.4);
    color: #6366f1;
}

/* --- Print: hide --- */
@media print {
    .cx-next-action { display: none !important; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .cx-na-toggle, .cx-na-panel, .cx-na-card, .cx-na-path-node {
        transition-duration: 0.01ms !important;
    }
    @keyframes cxNaDotPulse { 0%, 100% { transform: scale(1); } }
    @keyframes cxPathNodePulse { 0%, 100% { box-shadow: 0 2px 12px rgba(99,102,241,0.4); } }
}
