/* ======= Subject Tracking System ======= */

/* Subject Card on timer page */
.subject-card {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.subject-card:hover {
    transform: translateY(-1.04px);
    border-color: rgba(0, 230, 214, 0.3);
    box-shadow: 0 4.16px 12.48px rgba(0, 230, 214, 0.1);
}
.subject-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1.56px;
    background: linear-gradient(90deg, #00e6d6, #4ECDC4);
    opacity: 0.8;
}

/* ======= Subject Modal ======= */
.subject-modal-body {
    padding: 0.78rem 0;
}

/* Toggle Row */
.subject-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.78rem;
    background: var(--glass);
    border: 0.52px solid var(--glass-border);
    border-radius: 9.36px;
    margin-bottom: 1.04rem;
}

.subject-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.13rem;
}

.subject-toggle-title {
    font-size: 0.728rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.312rem;
}

.subject-toggle-desc {
    font-size: 0.52rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Toggle Switch */
.subject-toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.subject-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.subject-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.subject-toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.subject-toggle-switch input:checked + .subject-toggle-slider {
    background: linear-gradient(135deg, #00e6d6, #00b4d8);
    border-color: rgba(0, 230, 214, 0.4);
    box-shadow: 0 0 12px rgba(0, 230, 214, 0.2);
}

.subject-toggle-switch input:checked + .subject-toggle-slider::before {
    transform: translateX(16px);
    background: #fff;
}

/* Disabled State Overlay */
.subject-disabled-state {
    text-align: center;
    padding: 1.56rem 0.78rem;
    color: var(--muted);
}

.subject-disabled-icon {
    font-size: 2rem;
    margin-bottom: 0.52rem;
    opacity: 0.5;
    filter: grayscale(0.5);
}

.subject-disabled-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.26rem;
}

.subject-disabled-text {
    font-size: 0.572rem;
    line-height: 1.5;
    max-width: 260px;
    margin: 0 auto;
}

/* Subject Create Section */
.subject-create-section {
    background: var(--glass);
    border: 0.52px solid var(--glass-border);
    border-radius: 9.36px;
    padding: 0.65rem 0.78rem;
    margin-bottom: 0.78rem;
    display: flex;
    align-items: center;
    gap: 0.442rem;
}

.subject-create-input {
    flex: 1;
    padding: 0.52rem 0.676rem;
    background: var(--card);
    border: 1.04px solid rgba(255, 255, 255, 0.08);
    border-radius: 7.28px;
    color: var(--text);
    font-size: 0.676rem;
    font-family: inherit;
    transition: all 0.3s ease;
    min-width: 0;
}
.subject-create-input:focus {
    outline: none;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 0 1.56px rgba(0, 230, 214, 0.15);
}
.subject-create-input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.subject-add-btn {
    padding: 0.52rem 0.78rem;
    background: linear-gradient(135deg, #00e6d6, #00b4d8);
    color: #fff;
    border: none;
    border-radius: 7.28px;
    font-size: 0.598rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.26rem;
    transition: all 0.25s ease;
    box-shadow: 0 2.08px 7.28px rgba(0, 230, 214, 0.25);
    flex-shrink: 0;
}
.subject-add-btn:hover {
    transform: translateY(-0.52px);
    box-shadow: 0 3.12px 10.4px rgba(0, 230, 214, 0.35);
}
.subject-add-btn:active {
    transform: translateY(0);
}

.subject-count-badge {
    font-size: 0.494rem;
    color: var(--muted);
    text-align: right;
    margin-bottom: 0.39rem;
    font-weight: 500;
}

/* Subject List */
.subject-list {
    max-height: 260px;
    overflow-y: auto;
    padding-right: 0.13rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.subject-list::-webkit-scrollbar {
    width: 2.6px;
}
.subject-list::-webkit-scrollbar-track {
    background: transparent;
}
.subject-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2.08px;
}

/* Subject Item */
.subject-item {
    display: flex;
    align-items: center;
    gap: 0.52rem;
    padding: 0.52rem 0.65rem;
    border-radius: 8.32px;
    background: var(--glass);
    border: 0.52px solid var(--glass-border);
    margin-bottom: 0.312rem;
    transition: all 0.25s ease;
}
.subject-item:hover {
    border-color: rgba(0, 230, 214, 0.25);
    background: rgba(255, 255, 255, 0.04);
}

.subject-item-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.subject-item-color-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.subject-item-color-btn:hover {
    transform: scale(1.15);
}
.subject-item-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.subject-item-color-btn:hover .subject-item-color-dot {
    border-color: #fff;
    box-shadow: 0 0 10px var(--subj-color, rgba(0, 230, 214, 0.7));
}
.subject-item-color-icon {
    font-size: 7px;
    color: #fff;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.subject-item-color-btn:hover .subject-item-color-icon {
    opacity: 0.95;
    transform: scale(1);
}

/* Color picker button in subject creation bar */
.subject-color-picker-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.subject-color-trigger-btn {
    width: 28px;
    height: 28px;
    border-radius: 7.28px;
    background: var(--card, rgba(255, 255, 255, 0.04));
    border: 1.04px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0;
    transition: all 0.2s ease;
}
.subject-color-trigger-btn:hover {
    border-color: var(--neon-cyan, #00e6d6);
    box-shadow: 0 0 10px rgba(0, 230, 214, 0.25);
    transform: translateY(-0.52px);
}
.subject-color-dot-inner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.subject-color-palette-icon {
    position: absolute;
    font-size: 8px;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.subject-color-trigger-btn:hover .subject-color-palette-icon {
    opacity: 0.9;
}

/* Floating Subject Color Picker Popover */
.subject-color-popover {
    position: fixed;
    z-index: 100050;
    background: rgba(13, 17, 28, 0.97);
    border: 1px solid rgba(0, 230, 214, 0.3);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 24px rgba(0, 230, 214, 0.14);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    width: 220px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    animation: subjPopoverIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
    user-select: none;
}
@keyframes subjPopoverIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
.subject-color-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.subject-color-popover-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text, #f1f5f9);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    letter-spacing: 0.3px;
}
.subject-color-popover-title i {
    color: var(--neon-cyan, #00e6d6);
    font-size: 0.65rem;
}
.subject-color-popover-close {
    background: transparent;
    border: none;
    color: var(--muted, #94a3b8);
    cursor: pointer;
    font-size: 0.68rem;
    padding: 3px 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.subject-color-popover-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.subject-palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.45rem;
    margin-bottom: 0.6rem;
}
.subject-palette-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    padding: 0;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s, box-shadow 0.18s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.subject-palette-swatch:hover {
    transform: scale(1.18);
    border-color: #fff;
    box-shadow: 0 0 10px var(--swatch-color, #00e6d6);
    z-index: 2;
}
.subject-palette-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(13, 17, 28, 0.9), 0 0 12px var(--swatch-color, #00e6d6);
    transform: scale(1.08);
}
.subject-palette-swatch.active::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.subject-custom-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.45rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.subject-custom-color-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text, #f1f5f9);
}
.subject-custom-color-preview {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
    display: inline-block;
}
.subject-custom-color-input {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
    background: transparent;
}
.subject-custom-color-input::-webkit-color-swatch-wrapper {
    padding: 1px;
}
.subject-custom-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.subject-item-name {
    flex: 1;
    font-size: 0.728rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.subject-item-actions {
    display: flex;
    align-items: center;
    gap: 0.312rem;
    flex-shrink: 0;
}

.subject-edit-btn {
    width: 22px;
    height: 22px;
    border-radius: 6.24px;
    border: 0.52px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.52rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.subject-edit-btn:hover {
    border-color: var(--neon-cyan, #00e6d6);
    color: var(--neon-cyan, #00e6d6);
    background: rgba(0, 230, 214, 0.08);
    transform: scale(1.05);
    box-shadow: 0 0 8px rgba(0, 230, 214, 0.2);
}
.subject-edit-btn:active {
    transform: scale(0.95);
}

.subject-delete-btn {
    width: 22px;
    height: 22px;
    border-radius: 6.24px;
    border: 0.52px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.468rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.subject-delete-btn:hover {
    border-color: #ff4d6d;
    color: #ff4d6d;
    background: rgba(255, 77, 109, 0.08);
    transform: scale(1.05);
}
.subject-delete-btn:active {
    transform: scale(0.95);
}

.subject-empty-msg {
    color: var(--muted);
    text-align: center;
    padding: 1.3rem 0.52rem;
    font-size: 0.676rem;
    opacity: 0.8;
    line-height: 1.5;
}

/* ======= Subject Selector Modal (appears before timer start) ======= */
.subject-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.52rem;
    padding: 0.52rem 0;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.subject-select-grid::-webkit-scrollbar {
    width: 2.6px;
}
.subject-select-grid::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2.08px;
}

.subject-select-card {
    display: flex;
    align-items: center;
    gap: 0.442rem;
    padding: 0.65rem 0.78rem;
    border-radius: 9.36px;
    background: var(--glass);
    border: 1.04px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
    overflow: hidden;
}
.subject-select-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.subject-select-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 230, 214, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.subject-select-card:hover::before {
    opacity: 1;
}
.subject-select-card:active {
    transform: translateY(-1px) scale(0.98);
}

.subject-select-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.subject-select-name {
    font-size: 0.728rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-select-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.56rem;
    color: var(--muted);
    font-size: 0.676rem;
}

/* Inline create in selector modal */
.subject-select-create {
    display: flex;
    align-items: center;
    gap: 0.442rem;
    padding: 0.52rem 0;
    margin-top: 0.52rem;
    border-top: 0.52px solid var(--glass-border);
}

.subject-select-create-input {
    flex: 1;
    padding: 0.52rem 0.676rem;
    background: var(--card);
    border: 1.04px solid rgba(255, 255, 255, 0.08);
    border-radius: 7.28px;
    color: var(--text);
    font-size: 0.676rem;
    font-family: inherit;
    transition: all 0.3s ease;
    min-width: 0;
}
.subject-select-create-input:focus {
    outline: none;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 0 1.56px rgba(0, 230, 214, 0.15);
}
.subject-select-create-input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

/* ======= Subject Analytics Section ======= */
.subject-analytics-section {
    margin-bottom: 1.56rem;
}

.subject-analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.78rem;
    margin-bottom: 0.78rem;
}

.subject-chart-card {
    background: var(--card);
    backdrop-filter: blur(10.4px);
    border: 0.52px solid rgba(255, 255, 255, 0.08);
    border-radius: 12.48px;
    padding: 1.04rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.subject-chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.08px;
    background: linear-gradient(90deg, #00e6d6, #4ECDC4, #45B7D1);
    transform: scaleX(0);
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.subject-chart-card:hover::before {
    transform: scaleX(1);
}
.subject-chart-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(0, 230, 214, 0.2);
}

.subject-chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.78rem;
}

.subject-chart-title {
    font-size: 0.728rem;
    font-weight: 700;
    color: var(--text);
}

.subject-chart-subtitle {
    font-size: 0.494rem;
    color: var(--muted);
    margin-top: 0.13rem;
}

.subject-chart-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}

.subject-chart-canvas-wrap {
    position: relative;
    width: 100%;
    max-height: 220px;
}

.subject-chart-canvas-wrap canvas {
    max-height: 220px;
}

/* Subject Legend Card */
.subject-legend-card {
    background: var(--card);
    backdrop-filter: blur(10.4px);
    border: 0.52px solid rgba(255, 255, 255, 0.08);
    border-radius: 12.48px;
    padding: 0.78rem 1.04rem;
    box-shadow: var(--shadow);
}

.subject-legend-title {
    font-size: 0.624rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.52rem;
    display: flex;
    align-items: center;
    gap: 0.312rem;
}

.subject-legend-title i {
    color: var(--neon-cyan);
    font-size: 0.728rem;
}

.subject-legend-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.39rem 0.78rem;
}

.subject-legend-item {
    display: flex;
    align-items: center;
    gap: 0.312rem;
    font-size: 0.572rem;
    color: var(--muted);
    font-weight: 500;
}

.subject-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.subject-legend-time {
    font-weight: 600;
    color: var(--text);
    margin-left: 0.13rem;
    font-size: 0.52rem;
}

/* No subject data state */
.subject-analytics-empty {
    text-align: center;
    padding: 1.56rem;
    color: var(--muted);
    font-size: 0.624rem;
    opacity: 0.7;
}

.subject-analytics-empty i {
    font-size: 1.56rem;
    display: block;
    margin-bottom: 0.52rem;
    opacity: 0.4;
}

/* ======= Mobile Responsive ======= */
@media (max-width: 768px) {
    .subject-analytics-grid {
        grid-template-columns: 1fr;
    }

    .subject-select-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.39rem;
    }

    .subject-select-card {
        padding: 0.52rem 0.624rem;
    }

    .subject-select-name {
        font-size: 0.676rem;
    }

    .subject-toggle-row {
        padding: 0.52rem 0.624rem;
    }

    .subject-toggle-title {
        font-size: 0.676rem;
    }

    .subject-toggle-desc {
        font-size: 0.468rem;
    }

    .subject-create-section {
        flex-wrap: wrap;
    }

    .subject-create-input {
        flex: 1 1 100%;
    }

    .subject-add-btn {
        width: 100%;
        justify-content: center;
    }

    .subject-chart-canvas-wrap {
        max-height: 180px;
    }

    .subject-chart-canvas-wrap canvas {
        max-height: 180px;
    }

    .subject-legend-grid {
        gap: 0.312rem 0.52rem;
    }

    .subject-legend-item {
        font-size: 0.52rem;
    }
}

@media (max-width: 480px) {
    .subject-select-grid {
        grid-template-columns: 1fr 1fr;
    }

    .subject-select-create {
        flex-wrap: wrap;
    }

    .subject-select-create-input {
        flex: 1 1 100%;
    }
}

/* PC specific sizing adjustments */
@media (min-width: 768px) {
    /* 25% larger text for specific section titles */
    #subjectAnalyticsSection .section-title,
    #subjectAnalyticsSection + .charts-section-title .section-title {
        font-size: 1.25em;
    }

    /* subject modal width 2x, height comfortably spacious */
    #subjectModal .modal-content {
        max-width: 650px;
        max-height: min(88vh, 720px);
    }

    /* select subject modal width 1.7x, height comfortably spacious */
    #subjectSelectModal .modal-content {
        max-width: 550px;
        max-height: min(88vh, 720px);
    }
}

/* Fix invisible icons in section titles due to gradient text transparency */
.section-title .glass-icon-box i { -webkit-text-fill-color: currentColor; }
