/* ══════════════════════════════════════════════════════════════
   TrackPro Sidebar — Right-side slide-in tracking panel
   Follows the ai-sidebar pattern from the main app
   ══════════════════════════════════════════════════════════════ */

/* ─── Container & Panel ──────────────────────────────────── */
.tracking-sidebar-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-overlay);
    pointer-events: none;
    display: flex;
    justify-content: flex-end;
}

.tracking-sidebar {
    width: 460px;
    height: 100%;
    background: var(--bg-surface-solid);
    border-left: 1px solid var(--border-glass);
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: auto;
    z-index: var(--z-modal);
    position: relative;
    font-family: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

/* CRITICAL: iOS Safari requires pointer-events: auto on the CONTAINER 
   when open, not just the child. Touch events don't propagate through
   pointer-events: none parents on iOS/WebKit even if children have auto. */
.tracking-sidebar-container.open {
    pointer-events: auto;
}

/* ─── Side Handle Buttons ──────────────────────────────── */
.tracking-side-close-btn {
    position: absolute;
    top: calc(50% - 22px);
    left: -22px;
    width: 44px;
    height: 44px;
    background: var(--bg-surface-solid);
    border: 2px solid var(--border-glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.tracking-sidebar-container.open .tracking-side-close-btn {
    opacity: 1;
    pointer-events: auto;
}

.tracking-side-close-btn:hover {
    transform: scale(1.1);
    background: var(--bg-item-hover);
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* ─── Expand Edge Button (above close arrow) ─────────────── */
.tracking-side-expand-btn {
    position: absolute;
    top: calc(50% - 78px);
    left: -22px;
    width: 44px;
    height: 44px;
    background: var(--bg-surface-solid);
    border: 2px solid var(--border-glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    font-size: 0.9rem;
}

.tracking-sidebar-container.open .tracking-side-expand-btn {
    opacity: 1;
    pointer-events: auto;
}

.tracking-side-expand-btn:hover {
    transform: scale(1.1);
    background: rgba(74, 143, 217, 0.12);
    color: #4A8FD9;
    border-color: #4A8FD9;
    box-shadow: -4px 0 16px rgba(74, 143, 217, 0.25);
}

.tracking-side-expand-btn.expanded {
    color: #4A8FD9;
    background: rgba(74, 143, 217, 0.1);
    border-color: #4A8FD9;
}

/* ─── Expanded Sidebar State (80% viewport) ──────────────── */
.tracking-sidebar.expanded {
    width: 80vw;
}

.tracking-sidebar {
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ─── Sidebar Header ────────────────────────────────────── */
.tracking-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    flex-shrink: 0;
}

.tracking-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tracking-header-left .track-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #4A8FD9, #6BAAE8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(74, 143, 217, 0.3);
}

.tracking-header-left .track-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.tracking-header-left .track-badge {
    font-size: 0.65rem;
    background: rgba(74, 143, 217, 0.15);
    color: #4A8FD9;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid rgba(74, 143, 217, 0.25);
}

.tracking-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tracking-header-right .track-ctrl-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.tracking-header-right .track-ctrl-btn:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.tracking-header-right .close-tracking-btn {
    font-size: 1rem;
}

/* ─── Navigation Breadcrumb ──────────────────────────────── */
.tracking-nav-bar {
    padding: 8px 18px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    flex-shrink: 0;
}

.tracking-nav-bar .tn-back {
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tracking-nav-bar .tn-back:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
}

.tracking-nav-bar .tn-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tracking-nav-bar .tn-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

/* ─── Main Content Area ──────────────────────────────────── */
.tracking-body {
    flex: 1;
    min-height: 0;  /* CRITICAL: iOS flex scroll fix — without this, flex child expands to content size instead of scrolling */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: var(--bg-app);
    background-image: radial-gradient(circle at 20% 20%, rgba(74, 143, 217, 0.04) 0%, transparent 50%);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
}

/* ─── Views ──────────────────────────────────────────────── */
.tp-view {
    display: none;
    padding: 18px;
    animation: tpFadeIn 0.3s ease;
}

.tp-view.active {
    display: block;
}

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

/* ═══════════════════════════════════════════════════════════
   SETUP VIEW
   ═══════════════════════════════════════════════════════════ */
.tp-setup-container {
    text-align: center;
    padding: 10px 0;
}

.tp-setup-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #4A8FD9, #6BAAE8);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 8px 24px rgba(74, 143, 217, 0.3);
    animation: tpPulseGlow 2s infinite alternate;
}

@keyframes tpPulseGlow {
    from { box-shadow: 0 4px 16px rgba(74, 143, 217, 0.2); }
    to { box-shadow: 0 8px 32px rgba(74, 143, 217, 0.35); }
}

.tp-setup-title {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4A8FD9, #6BAAE8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.tp-setup-subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 20px;
}

.tp-setup-form {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px;
    text-align: left;
}

/* ─── Shared Form Styles ──────────────────────────────────── */
.tp-form-group {
    margin-bottom: 14px;
}

.tp-form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tp-form-group input,
.tp-form-group select,
.tp-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.tp-form-group input:focus,
.tp-form-group select:focus,
.tp-form-group textarea:focus {
    border-color: #4A8FD9;
    box-shadow: 0 0 0 3px rgba(74, 143, 217, 0.15);
}

.tp-form-group input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.tp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ─── Shared Button Styles ────────────────────────────────── */
.tp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    position: relative;
    overflow: hidden;
}

.tp-btn-primary {
    background: linear-gradient(135deg, #4A8FD9, #3A7BC8);
    color: white;
    box-shadow: 0 4px 12px rgba(74, 143, 217, 0.25);
}

.tp-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(74, 143, 217, 0.35);
    transform: translateY(-1px);
}

.tp-btn-secondary {
    background: var(--bg-item);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.tp-btn-secondary:hover {
    background: var(--bg-item-hover);
    border-color: var(--text-muted);
}

.tp-btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.tp-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.tp-btn-sm {
    padding: 7px 12px;
    font-size: 0.75rem;
}

.tp-btn-full {
    width: 100%;
}

.tp-btn-lg {
    padding: 12px 24px;
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD VIEW
   ═══════════════════════════════════════════════════════════ */
.tp-welcome {
    background: linear-gradient(135deg, rgba(74, 143, 217, 0.08), rgba(107, 170, 232, 0.06));
    border: 1px solid rgba(74, 143, 217, 0.15);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 16px;
}

.tp-welcome h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-main);
}

.tp-welcome p {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.tp-stats-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.tp-stat-badge {
    text-align: center;
    padding: 6px 14px;
    background: var(--bg-item);
    border-radius: 10px;
    border: 1px solid var(--border-glass);
    flex: 1;
}

.tp-stat-badge .tp-stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #4A8FD9;
}

.tp-stat-badge .tp-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Class Cards */
.tp-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tp-classes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tp-class-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.tp-class-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #4A8FD9, #6BAAE8);
    opacity: 0;
    transition: opacity 0.25s;
}

.tp-class-card:hover {
    border-color: #4A8FD9;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(74, 143, 217, 0.12);
}

.tp-class-card:hover::before {
    opacity: 1;
}

.tp-class-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tp-class-card h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

.tp-class-card-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tp-class-card-actions {
    display: flex;
    gap: 4px;
}

.tp-class-card-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    transition: all 0.15s;
}

.tp-class-card-actions button:hover {
    color: var(--text-main);
    background: var(--bg-item-hover);
}

.tp-class-card-actions button.tp-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.tp-class-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-glass);
}

.tp-class-student-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.tp-class-btns {
    display: flex;
    gap: 6px;
}

/* Archived Classes Folder (TrackPro Dashboard) */
.tp-class-card.archived {
    opacity: 0.75;
    filter: grayscale(0.55);
    transition: opacity 0.2s, filter 0.2s;
}
.tp-class-card.archived:hover {
    opacity: 1;
    filter: grayscale(0);
}
.tp-archive-group {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-glass);
}
.tp-archive-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
    user-select: none;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
}
.tp-archive-header:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}
.tp-archive-header .tp-archive-arrow {
    margin-left: auto;
    font-size: 0.72rem;
    transition: transform 0.3s;
}
.tp-archive-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 10px;
}

/* New Class Button */
.tp-new-class-btn {
    background: transparent;
    border: 2px dashed var(--border-glass);
    border-radius: 12px;
    padding: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.25s;
    font-family: inherit;
    width: 100%;
}

.tp-new-class-btn:hover {
    border-color: #4A8FD9;
    color: #4A8FD9;
    background: rgba(74, 143, 217, 0.05);
}

/* ═══════════════════════════════════════════════════════════
   CLASS DETAIL VIEW
   ═══════════════════════════════════════════════════════════ */
.tp-student-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.tp-student-input-group input {
    flex: 1;
    padding: 9px 12px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
}

.tp-student-input-group input:focus {
    border-color: #4A8FD9;
}

.tp-student-input-group input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.tp-student-id-input {
    max-width: 120px;
    flex: 0 1 120px !important;
}

.tp-student-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tp-student-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    margin-bottom: 6px;
    transition: all 0.15s;
}

.tp-student-list-item:hover {
    border-color: #4A8FD9;
    background: var(--bg-item-hover);
}

.tp-student-number {
    width: 24px;
    height: 24px;
    background: rgba(74, 143, 217, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #4A8FD9;
    flex-shrink: 0;
}

.tp-student-id-badge {
    padding: 2px 8px;
    background: rgba(74, 143, 217, 0.1);
    color: #4A8FD9;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    flex-shrink: 0;
}

.tp-student-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-main);
}

.tp-student-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.tp-student-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Bulk Add */
.tp-bulk-area {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-glass);
}

.tp-bulk-area label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tp-bulk-area textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.8rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
    margin-top: 6px;
    transition: border-color 0.2s;
}

.tp-bulk-area textarea:focus {
    border-color: #4A8FD9;
}

.tp-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   TRACKING VIEW — Header Block
   ═══════════════════════════════════════════════════════════ */

/* ── Date + Search row ── */
.tp-tracking-top-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.tp-tracking-date {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tp-tracking-date input[type="date"] {
    padding: 8px 11px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.tp-tracking-date input[type="date"]:focus {
    border-color: #4A8FD9;
}

.tp-tracking-date .tp-today-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 8px 11px;
}

/* Bulk Actions Bar */
.tp-bulk-actions {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
}

.tp-bulk-select-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 10px;
    border-right: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.tp-bulk-select-group label {
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: pointer;
}

.tp-checkbox {
    width: 16px;
    height: 16px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-item);
    border: 2px solid var(--border-glass);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
}

.tp-checkbox:checked {
    background: #4A8FD9;
    border-color: #4A8FD9;
}

.tp-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
}

.tp-bulk-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}

.tp-bulk-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: white;
}

.tp-bulk-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.tp-bulk-btn.star { background: #E4A322; }
.tp-bulk-btn.response { background: #2EA87A; }
.tp-bulk-btn.passive { background: #D95555; }
.tp-bulk-btn.alef { background: #4A8FD9; }
.tp-bulk-btn.lms { background: #7B6CD9; }

.tp-selected-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

.tp-bulk-actions-row2 {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    margin-top: -6px;
}

.tp-bulk-actions-row2 .tp-btn {
    font-size: 0.68rem;
    padding: 5px 10px;
    flex: 1;
}

.tp-bulk-actions-row2 #tp-btn-edit-activity {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.25);
}

.tp-bulk-actions-row2 #tp-btn-edit-activity:hover {
    background: rgba(99, 102, 241, 0.22);
}

/* Tracking Grid */
.tp-tracking-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.tp-track-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 12px 14px;
    transition: all 0.15s;
    position: relative;
}

.tp-track-card.selected {
    border-color: #4A8FD9;
    box-shadow: 0 0 0 2px rgba(74, 143, 217, 0.2);
}

.tp-track-card.colored-card {
    border-left: 3px solid var(--card-accent-color, var(--border-glass));
}

.tp-track-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.tp-track-checkbox {
    flex-shrink: 0;
}

.tp-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A8FD9, #6BAAE8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.72rem;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.tp-track-card.colored-card .tp-avatar {
    background: var(--card-accent-color, linear-gradient(135deg, #4A8FD9, #6BAAE8));
}

.tp-track-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-main);
    line-height: 1.2;
}

.tp-track-id {
    font-size: 0.65rem;
    color: #4A8FD9;
    font-weight: 600;
}

/* Track Buttons */
.tp-track-buttons {
    display: flex;
    gap: 4px;
}

.tp-track-btn {
    flex: 1;
    min-width: 36px;
    height: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    position: relative;
}

.tp-track-btn .tp-track-icon {
    font-size: 14px;
    line-height: 1;
}

.tp-track-btn .tp-track-count {
    font-size: 0.55rem;
    font-weight: 700;
    line-height: 1;
    opacity: 0.9;
}

.tp-track-btn.star { background: rgba(228, 163, 34, 0.12); color: #E4A322; }
.tp-track-btn.star:hover, .tp-track-btn.star.active-pulse { background: rgba(228, 163, 34, 0.28); box-shadow: 0 0 10px rgba(228, 163, 34, 0.25); }
.tp-track-btn.response { background: rgba(46, 168, 122, 0.12); color: #2EA87A; }
.tp-track-btn.response:hover, .tp-track-btn.response.active-pulse { background: rgba(46, 168, 122, 0.28); box-shadow: 0 0 10px rgba(46, 168, 122, 0.25); }
.tp-track-btn.passive { background: rgba(217, 85, 85, 0.12); color: #D95555; }
.tp-track-btn.passive:hover, .tp-track-btn.passive.active-pulse { background: rgba(217, 85, 85, 0.28); box-shadow: 0 0 10px rgba(217, 85, 85, 0.25); }
.tp-track-btn.alef { background: rgba(74, 143, 217, 0.12); color: #4A8FD9; }
.tp-track-btn.alef:hover, .tp-track-btn.alef.active-pulse { background: rgba(74, 143, 217, 0.28); box-shadow: 0 0 10px rgba(74, 143, 217, 0.25); }
.tp-track-btn.lms { background: rgba(123, 108, 217, 0.12); color: #7B6CD9; }
.tp-track-btn.lms:hover, .tp-track-btn.lms.active-pulse { background: rgba(123, 108, 217, 0.28); box-shadow: 0 0 10px rgba(123, 108, 217, 0.25); }

@keyframes tpBtnPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.tp-track-btn.pulse-anim {
    animation: tpBtnPulse 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════
   REPORTS VIEW
   ═══════════════════════════════════════════════════════════ */
.tp-report-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.tp-report-controls select,
.tp-report-controls input[type="date"] {
    padding: 7px 10px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
}

.tp-report-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.tp-summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    transition: all 0.15s;
}

.tp-summary-card:hover {
    transform: translateY(-1px);
}

.tp-summary-card .tp-sum-icon { font-size: 16px; margin-bottom: 4px; }
.tp-summary-card .tp-sum-value { font-size: 1.1rem; font-weight: 800; line-height: 1; margin-bottom: 2px; }
.tp-summary-card .tp-sum-label { font-size: 0.55rem; color: var(--text-muted); text-transform: uppercase; }

.tp-summary-card.star .tp-sum-value { color: #E4A322; }
.tp-summary-card.response .tp-sum-value { color: #2EA87A; }
.tp-summary-card.passive .tp-sum-value { color: #D95555; }
.tp-summary-card.alef .tp-sum-value { color: #4A8FD9; }
.tp-summary-card.lms .tp-sum-value { color: #7B6CD9; }

/* Report Table */
.tp-table-wrapper {
    overflow-x: auto;
    margin-bottom: 14px;
    border-radius: 10px;
    border: 1px solid var(--border-glass);
    -webkit-overflow-scrolling: touch;
}

.tp-report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.tp-report-table thead {
    background: var(--bg-surface);
}

.tp-report-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}

.tp-report-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-main);
}

.tp-report-table tbody tr:hover {
    background: var(--bg-item-hover);
}

.tp-report-table tbody tr:last-child td {
    border-bottom: none;
}

.tp-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 11px;
    font-weight: 700;
    font-size: 0.7rem;
}

.tp-count-badge.star { background: rgba(228, 163, 34, 0.12); color: #E4A322; }
.tp-count-badge.response { background: rgba(46, 168, 122, 0.12); color: #2EA87A; }
.tp-count-badge.passive { background: rgba(217, 85, 85, 0.12); color: #D95555; }
.tp-count-badge.alef { background: rgba(74, 143, 217, 0.12); color: #4A8FD9; }
.tp-count-badge.lms { background: rgba(123, 108, 217, 0.12); color: #7B6CD9; }

/* Chart */
.tp-chart-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.tp-chart-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.tp-chart-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tp-chart-label {
    width: 80px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-chart-track {
    flex: 1;
    height: 20px;
    background: var(--bg-item);
    border-radius: 10px;
    overflow: hidden;
}

.tp-chart-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(90deg, #4A8FD9, #6BAAE8);
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS VIEW
   ═══════════════════════════════════════════════════════════ */
.tp-settings-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
}

.tp-settings-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
}

.tp-settings-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tp-backup-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-item);
    border-radius: 8px;
    margin-bottom: 12px;
}

.tp-backup-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2EA87A;
    animation: tpPulseDot 2s infinite;
}

@keyframes tpPulseDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.tp-backup-text {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ─── Empty State ────────────────────────────────────────── */
.tp-empty-state {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-muted);
}

.tp-empty-state .tp-empty-icon {
    font-size: 36px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.tp-empty-state h4 {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.tp-empty-state p {
    font-size: 0.72rem;
    max-width: 240px;
    margin: 0 auto;
}

/* ─── Toast (Tracking internal) ──────────────────────────── */
.tp-toast-container {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.tp-toast {
    padding: 10px 16px;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: tpToastIn 0.3s ease, tpToastOut 0.3s ease 2.2s forwards;
    pointer-events: auto;
}

.tp-toast.success { border-left: 3px solid #2EA87A; }
.tp-toast.error { border-left: 3px solid #D95555; }
.tp-toast.info { border-left: 3px solid #4A8FD9; }

@keyframes tpToastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tpToastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(10px); }
}

/* ─── Modal (inside sidebar) ─────────────────────────────── */
.tp-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.tp-modal-overlay.active {
    display: flex;
}

.tp-modal {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-height: 80%;
    overflow-y: auto;
    animation: tpFadeIn 0.25s ease;
}

.tp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tp-modal-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.tp-modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.tp-modal-close:hover {
    color: var(--text-main);
    background: var(--bg-item-hover);
}

.tp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-glass);
}

/* ─── Edit All Marks Spreadsheet ─────────────────────────── */
.tp-eam-wrap {
    overflow: auto;
    max-height: 55vh;
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    background: var(--bg-surface);
}
.tp-eam-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.tp-eam-table th {
    position: sticky;
    top: 0;
    background: var(--bg-surface-solid);
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 8px 6px;
    text-align: center;
    border-bottom: 2px solid var(--border-glass);
    z-index: 2;
    white-space: nowrap;
}
.tp-eam-table th:first-child {
    text-align: left;
    padding-left: 12px;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface-solid);
}
.tp-eam-table td {
    padding: 4px 3px;
    text-align: center;
    border-bottom: 1px solid var(--border-glass);
    vertical-align: middle;
}
.tp-eam-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}
.tp-eam-name {
    font-weight: 600;
    color: var(--text-main);
    text-align: left !important;
    padding: 8px 12px !important;
    white-space: nowrap;
    position: sticky;
    left: 0;
    background: var(--bg-surface);
    z-index: 1;
    border-right: 1px solid var(--border-glass);
}
.tp-eam-table tbody tr:hover .tp-eam-name {
    background: rgba(99, 102, 241, 0.05);
}
.tp-eam-input {
    width: 52px;
    padding: 4px 2px;
    text-align: center;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    transition: border-color 0.15s;
}
.tp-eam-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.tp-eam-input:hover {
    border-color: rgba(99, 102, 241, 0.4);
}
.tp-eam-weight {
    display: block;
    font-size: 0.55rem;
    font-weight: 600;
    opacity: 0.65;
    line-height: 1.2;
}
.tp-btn-xs {
    font-size: 0.7rem;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    height: auto !important;
    min-height: auto !important;
}

/* ─── Report Export Buttons ──────────────────────────────── */
.tp-export-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ─── Report Student Picker Section ─────────────────────── */
.tp-report-student-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.tp-rpt-pick-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-item);
}

.tp-rpt-pick-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-main);
}

.tp-rpt-pick-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: #4A8FD9;
    background: rgba(74, 143, 217, 0.12);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.tp-pick-toggle {
    margin-left: auto;
    padding: 3px 10px;
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tp-pick-toggle + .tp-pick-toggle {
    margin-left: 0;
}

.tp-btn-select-all:hover {
    background: rgba(74, 143, 217, 0.1);
    border-color: #4A8FD9;
    color: #4A8FD9;
}

.tp-btn-unselect-all:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
    color: #ef4444;
}

.tp-report-student-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    max-height: 130px;
    overflow-y: auto;
}

.tp-report-student-picker:empty::after {
    content: 'Select a class above to see students';
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-style: italic;
}

.tp-report-student-option {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    user-select: none;
}

.tp-report-student-option:hover {
    border-color: #4A8FD9;
    background: rgba(74, 143, 217, 0.08);
}

.tp-report-student-option:has(input:checked) {
    background: rgba(74, 143, 217, 0.14);
    border-color: #4A8FD9;
    color: #4A8FD9;
    font-weight: 600;
}

.tp-report-student-option .tp-checkbox {
    width: 14px;
    height: 14px;
}

/* ─── Button Config Grid (Settings) ─────────────────────── */
.tp-btn-config-grid {
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 12px;
    overflow: hidden;
}

.tp-btn-config-header {
    display: grid;
    grid-template-columns: 48px 1fr 80px;
    gap: 8px;
    padding: 0 4px 8px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 8px;
}

.tp-btn-config-header span {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.tp-btn-config-row {
    display: grid;
    grid-template-columns: 48px 1fr 80px;
    gap: 8px;
    align-items: center;
    padding: 6px 4px;
    border-radius: 8px;
    transition: background 0.15s;
    border-left: 3px solid var(--accent, var(--border-glass));
    margin-bottom: 4px;
}

.tp-btn-config-row:hover {
    background: var(--bg-item-hover);
}

.tp-icon-input {
    width: 100%;
    text-align: center;
    font-size: 1.1rem;
    padding: 6px 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.tp-icon-input:focus {
    border-color: var(--accent, #4A8FD9);
}

.tp-name-input {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s;
}

.tp-name-input:focus {
    border-color: var(--accent, #4A8FD9);
}

.tp-name-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.tp-weight-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0 8px 0 0;
    overflow: hidden;
    transition: border-color 0.2s;
}

.tp-weight-wrap:focus-within {
    border-color: var(--accent, #4A8FD9);
}

.tp-weight-input {
    width: 100%;
    padding: 7px 6px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    outline: none;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.tp-weight-input::-webkit-inner-spin-button,
.tp-weight-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.tp-weight-wrap span {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.tp-weight-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 8px 2px;
    margin-top: 6px;
    border-top: 1px solid var(--border-glass);
}

.tp-weight-total-bar span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.tp-weight-total-bar strong {
    font-size: 0.85rem;
    font-weight: 800;
    transition: color 0.2s;
}

/* ─── Report Options Modal ──────────────────────────────── */
.tp-rpt-options {
    padding: 4px 0;
}

.tp-rpt-opt-group {
    margin-bottom: 16px;
}

.tp-rpt-opt-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
}

.tp-rpt-opt-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tp-rpt-opt-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px 10px;
    background: var(--bg-item);
    border: 2px solid var(--border-glass);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
}

.tp-rpt-opt-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tp-rpt-opt-card:hover {
    border-color: rgba(74, 143, 217, 0.4);
    background: var(--bg-item-hover);
}

.tp-rpt-opt-card.active {
    border-color: #4A8FD9;
    background: rgba(74, 143, 217, 0.08);
    box-shadow: 0 0 0 3px rgba(74, 143, 217, 0.12);
}

.tp-rpt-opt-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.tp-rpt-opt-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.tp-rpt-opt-card.active .tp-rpt-opt-title {
    color: #4A8FD9;
}

.tp-rpt-opt-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════
   TOUCH & SCROLL SUPPORT
   ═══════════════════════════════════════════════════════════ */

/* Smooth momentum scrolling for all scrollable areas */
.tracking-body,
.tp-table-wrapper,
.tp-report-student-picker,
.tp-student-list,
.tp-tracking-grid,
.tp-modal-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Allow vertical scrolling by touch on scrollable containers */
.tracking-body {
    touch-action: pan-y;
}

.tp-view {
    touch-action: pan-y;
}

.tp-tracking-grid {
    touch-action: pan-y;
}

.tp-student-list {
    touch-action: pan-y;
}

/* Track cards: allow vertical scroll through them */
.tp-track-card {
    touch-action: pan-y;
}

/* Buttons inside cards: tap only, no scroll blocking */
.tp-track-btn,
.tp-btn,
.tp-pick-toggle,
.tp-report-student-option,
.tp-rpt-opt-card,
.tp-bulk-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Class cards: allow scroll through + tap */
.tp-class-card {
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent sidebar from blocking page scroll when closed */
.tracking-sidebar-container:not(.open) {
    pointer-events: none;
    touch-action: none;
}

/* Scrollbar styling for touch-scroll hybrid devices */
.tracking-body::-webkit-scrollbar,
.tp-report-student-picker::-webkit-scrollbar,
.tp-student-list::-webkit-scrollbar,
.tp-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tracking-body::-webkit-scrollbar-track,
.tp-report-student-picker::-webkit-scrollbar-track,
.tp-student-list::-webkit-scrollbar-track,
.tp-table-wrapper::-webkit-scrollbar-track {
    background: rgba(128, 128, 128, 0.06);
    border-radius: 4px;
}

.tracking-body::-webkit-scrollbar-thumb,
.tp-report-student-picker::-webkit-scrollbar-thumb,
.tp-student-list::-webkit-scrollbar-thumb,
.tp-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 40px;
}

.tracking-body::-webkit-scrollbar-thumb:hover,
.tp-report-student-picker::-webkit-scrollbar-thumb:hover,
.tp-student-list::-webkit-scrollbar-thumb:hover,
.tp-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.45);
}

/* Mobile-specific touch improvements */
@media (pointer: coarse) {
    .tp-track-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .tp-btn-sm {
        min-height: 38px;
        padding: 8px 14px;
    }

    .tp-report-student-option {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .tp-pick-toggle {
        padding: 6px 12px;
        font-size: 0.7rem;
    }

    .tp-checkbox {
        width: 18px;
        height: 18px;
    }

    .tp-icon-input,
    .tp-name-input,
    .tp-weight-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .tp-modal {
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ══════════════════════════════════════════════════════════════
   RTL Sidebar Overrides (Arabic mode)
   The outer container remains LTR for correct right-side anchoring.
   RTL dir is applied to the inner .tracking-sidebar panel only.
   ══════════════════════════════════════════════════════════════ */

/* Flip back-arrow icon for RTL */
.rtl-sidebar .tn-back .fas {
    transform: scaleX(-1);
}

/* Nav subtitle alignment */
.rtl-sidebar .tracking-nav-bar .tn-subtitle {
    margin-left: 0;
    margin-right: auto;
}

/* Setup form text alignment */
.rtl-sidebar .tp-setup-form {
    text-align: right;
}

/* Bulk select border flip */
.rtl-sidebar .tp-bulk-select-group {
    padding-right: 0;
    padding-left: 10px;
    border-right: none;
    border-left: 1px solid var(--border-glass);
}

/* ══════════════════════════════════════════════════════════════
   ACTIVITY SCORES & CREDENTIAL SYSTEM (v2)
   ══════════════════════════════════════════════════════════════ */

/* Activity score badges shown on tracking cards */
.tp-act-scores-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 0 2px;
    border-top: 1px solid var(--border-glass);
    margin-top: 4px;
}

.tp-act-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    transition: transform 0.15s;
}

.tp-act-badge:hover {
    transform: scale(1.05);
}

/* Credential pill shown in tracking card header */
.tp-cred-pill {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.25);
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Credential tag in student list */
.tp-cred-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.2);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    letter-spacing: 0.8px;
}

.tp-cred-tag:hover {
    background: rgba(99, 102, 241, 0.22);
    transform: scale(1.05);
}

/* "+ PIN" button for students without credential */
.tp-set-cred-btn {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-glass);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    font-family: inherit;
}

.tp-set-cred-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.3);
    border-style: solid;
}

/* Credential input in modal */
#tp-cred-input {
    width: 100%;
    padding: 14px;
    background: var(--bg-item);
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    color: var(--text-main);
    font-family: 'Source Code Pro', monospace, inherit;
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#tp-cred-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}


/* ═══════════════════════════════════════════════════════════
   SEARCH BAR (inline in top row)
   ═══════════════════════════════════════════════════════════ */
.tp-search-bar-wrap {
    position: relative;
    /* sits in the grid column — fills remaining space */
}

.tp-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.75rem;
    pointer-events: none;
}

.tp-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px 8px 30px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tp-search-input:focus {
    border-color: #4A8FD9;
    box-shadow: 0 0 0 3px rgba(74, 143, 217, 0.13);
}

.tp-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.65;
}

/* ═══════════════════════════════════════════════════════════
   ACTIVITY FILTER PILLS BAR — symmetric grid
   ═══════════════════════════════════════════════════════════ */
.tp-tracking-filter-bar {
    display: grid;
    /* Auto-fill columns: each pill at least 110px, max 1fr */
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
    margin-bottom: 10px;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
}

.tp-filter-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    border: 1px solid var(--border-glass);
    border-radius: 9px;
    background: var(--bg-item);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.2,0.8,0.2,1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.tp-filter-pill:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
    border-color: rgba(74, 143, 217, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* "All" pill — slightly wider and blue-tinted when active */
.tp-filter-pill:first-child {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tp-filter-pill.active {
    background: rgba(74, 143, 217, 0.15);
    color: #4A8FD9;
    border-color: rgba(74, 143, 217, 0.45);
    box-shadow: 0 0 0 1px rgba(74, 143, 217, 0.2) inset;
}

/* Negative-type pills: red-tinted border */
.tp-filter-pill.negative-type {
    border-color: rgba(217, 85, 85, 0.3);
    color: #D95555;
}

.tp-filter-pill.negative-type.active {
    background: rgba(217, 85, 85, 0.12);
    color: #D95555;
    border-color: rgba(217, 85, 85, 0.45);
    box-shadow: 0 0 0 1px rgba(217, 85, 85, 0.18) inset;
}

/* ═══════════════════════════════════════════════════════════
   NEGATIVE TYPE INDICATOR on Tracking Buttons
   ═══════════════════════════════════════════════════════════ */
.tp-track-btn.is-negative-type {
    border: 1px dashed rgba(217, 85, 85, 0.38) !important;
}

.tp-neg-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 7px;
    line-height: 1;
    opacity: 0.75;
    pointer-events: none;
}

/* Small ▼ on negative pills (replaces ::after text) */
.tp-filter-pill.negative-type .tp-neg-pill-arrow {
    font-size: 0.5rem;
    opacity: 0.6;
    color: #D95555;
}
