/* StudyPlanner Dashboard — Widget Grid & Components */

/* Dashboard Grid */
.dashboard-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    padding: 1.25rem;
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .dashboard-container {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

/* Widget Card */
.dashboard-widget {
    transition: transform 0.15s ease;
    animation: fadeInUp 0.25s ease-out;
    animation-fill-mode: both;
}

.dashboard-widget:nth-child(1) {
    animation-delay: 0.03s;
}

.dashboard-widget:nth-child(2) {
    animation-delay: 0.06s;
}

.dashboard-widget:nth-child(3) {
    animation-delay: 0.09s;
}

.dashboard-widget:nth-child(4) {
    animation-delay: 0.12s;
}

.dashboard-widget:nth-child(5) {
    animation-delay: 0.15s;
}

.dashboard-widget:nth-child(6) {
    animation-delay: 0.18s;
}

.dashboard-widget:nth-child(7) {
    animation-delay: 0.21s;
}

.dashboard-widget:nth-child(8) {
    animation-delay: 0.24s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-widget[data-size="large"] {
    grid-column: span 2;
}

@media (max-width: 1024px) {
    .dashboard-widget[data-size="large"] {
        grid-column: span 1;
    }
}

.dashboard-widget .card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    height: 100%;
    transition: border-color var(--transition-fast);
}

.dashboard-widget .card:hover {
    border-color: var(--border-light);
}

.dashboard-widget .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-default);
    padding: 0.875rem 1.125rem;
}

.dashboard-widget .card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dashboard-widget .card-body {
    padding: 1.125rem;
}

/* Sortable States */
.widget-ghost {
    opacity: 0.3;
    background: var(--bg-surface-2);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg);
}

.widget-dragging {
    transform: scale(1.01);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    cursor: grabbing;
}

/* Widget Minimize */
.widget-minimized .card-body {
    display: none;
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast),
        color var(--transition-fast);
}

.btn-ghost:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

/* Daily Goal */
#dailyGoalChart {
    max-width: 220px;
    margin: 0 auto;
}

#dailyGoalText {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Weekly Chart */
#weeklyChart {
    min-height: 250px;
}

/* Task List */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem;
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast),
        border-color var(--transition-fast);
    border: 1px solid transparent;
}

.task-item:hover {
    background: var(--bg-surface-3);
    border-color: var(--border-default);
}

.task-item.completed {
    opacity: 0.6;
}

.task-item.completed .task-subject-name {
    text-decoration: line-through;
}

.task-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
    flex-shrink: 0;
}

.task-color-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-subject-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-time {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.task-progress {
    text-align: right;
    flex-shrink: 0;
}

.task-progress-badge {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--bg-surface-2);
    color: var(--text-secondary);
}

.task-progress-badge.completed {
    background: var(--color-success-subtle);
    color: var(--color-success);
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.4;
    margin-bottom: 0.75rem;
}

/* Quick Timer */
.timer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-weight: 500;
    border: 1px solid var(--accent-primary);
    background: transparent;
    color: var(--accent-primary-light);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast);
    cursor: pointer;
}

.timer-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-1px);
}

.timer-btn:active {
    transform: translateY(0);
}

/* Achievements */
.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: 300px;
    overflow-y: auto;
}

.achievement-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.625rem;
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.achievement-item:hover {
    background: var(--bg-surface-3);
}

.achievement-item.new {
    border: 1px solid var(--accent-primary);
}

.achievement-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: white;
    flex-shrink: 0;
}

.achievement-info {
    flex: 1;
    min-width: 0;
}

.achievement-title {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.achievement-description {
    font-size: 0.6875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.achievement-date {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Streak Chain */
.streak-chain {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}

.streak-day {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    border: 2px solid var(--border-default);
    transition: background-color var(--transition-fast),
        border-color var(--transition-fast);
    position: relative;
}

.streak-day.active {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-color: transparent;
}

.streak-day .day-label {
    font-size: 0.5625rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.streak-day.active .day-label {
    color: white;
}

.streak-day .fire-icon {
    font-size: 0.875rem;
    display: none;
}

.streak-day.active .fire-icon {
    display: block;
}

/* Leaderboard */
.leaderboard-preview {
    max-height: 350px;
    overflow-y: auto;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border-default);
    transition: background-color var(--transition-fast);
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.leaderboard-row:hover {
    background: var(--bg-surface-2);
}

.leaderboard-row.current-user {
    background: var(--accent-primary-subtle);
    border-left: 3px solid var(--accent-primary);
}

.leaderboard-rank {
    width: 30px;
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.leaderboard-rank.gold {
    color: #fbbf24;
    font-size: 1rem;
}

.leaderboard-rank.silver {
    color: #94a3b8;
    font-size: 1rem;
}

.leaderboard-rank.bronze {
    color: #b45309;
    font-size: 1rem;
}

.leaderboard-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: white;
    margin: 0 0.625rem;
    flex-shrink: 0;
}

.leaderboard-info {
    flex: 1;
    min-width: 0;
}

.leaderboard-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-level {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.leaderboard-minutes {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--accent-primary-light);
    text-align: right;
}

/* Subject Progress */
.subject-progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.subject-progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.subject-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subject-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.subject-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.subject-stats {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.subject-progress-bar {
    height: 6px;
    background: var(--bg-surface-2);
    border-radius: 3px;
    overflow: hidden;
}

.subject-progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Widget Settings */
#widgetOrderList .list-group-item {
    background: var(--bg-surface-2);
    border-color: var(--border-default);
    color: var(--text-primary);
    cursor: move;
    padding: 0.625rem 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

#widgetOrderList .list-group-item:hover {
    background: var(--bg-surface-3);
}

#widgetOrderList .list-group-item i {
    color: var(--text-muted);
}

/* Scrollbar */
.task-list::-webkit-scrollbar,
.achievements-list::-webkit-scrollbar,
.leaderboard-preview::-webkit-scrollbar {
    width: 5px;
}

.task-list::-webkit-scrollbar-track,
.achievements-list::-webkit-scrollbar-track,
.leaderboard-preview::-webkit-scrollbar-track {
    background: var(--bg-surface-2);
    border-radius: 3px;
}

.task-list::-webkit-scrollbar-thumb,
.achievements-list::-webkit-scrollbar-thumb,
.leaderboard-preview::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

.task-list::-webkit-scrollbar-thumb:hover,
.achievements-list::-webkit-scrollbar-thumb:hover,
.leaderboard-preview::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-surface-2) 25%,
            var(--bg-surface-3) 50%,
            var(--bg-surface-2) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 0.375rem;
}

.skeleton-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}