/* ==========================================
   SysTasks - Bouton taskbar + Panel
   ========================================== */

/* Bouton taskbar */
.systasks-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    user-select: none;
}

.systasks-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.systasks-btn.active {
    background: rgba(6, 182, 212, 0.15);
}

.systasks-btn svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-secondary, #a0aec0);
    stroke-width: 1.5;
    fill: none;
    transition: stroke 0.2s, filter 0.2s;
}

.systasks-btn:hover svg {
    stroke: var(--text-primary, #f0f0f5);
}

.systasks-btn.active svg {
    stroke: #06b6d4;
}

.systasks-btn.has-tasks svg {
    stroke: #06b6d4;
    filter: drop-shadow(0 0 4px rgba(6, 182, 212, 0.5));
}

.systasks-btn.pulse svg {
    animation: systasks-pulse 2s ease-in-out infinite;
}

@keyframes systasks-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(6, 182, 212, 0.4)); }
    50% { filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.8)); }
}

/* Badge */
.systasks-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: #06b6d4;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 6px rgba(6, 182, 212, 0.5);
}

/* Panel */
.systasks-panel {
    position: fixed;
    bottom: calc(var(--taskbar-height, 56px) + 8px);
    right: 8px;
    width: 400px;
    max-height: calc(100vh - var(--taskbar-height, 56px) - 24px);
    background: rgba(12, 14, 20, 0.96);
    border: 1px solid rgba(6, 182, 212, 0.15);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 24px rgba(6, 182, 212, 0.08);
    backdrop-filter: blur(20px);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 10001;
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.systasks-panel.open {
    display: flex;
}

/* Header */
.systasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.systasks-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #f0f0f5);
    letter-spacing: 0.2px;
}

.systasks-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #a0aec0);
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.systasks-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #f0f0f5);
}

/* Stats counters */
.systasks-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
}

.systasks-counter {
    text-align: center;
    padding: 6px 0;
}

.systasks-counter-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.systasks-counter-label {
    font-size: 10px;
    color: var(--text-secondary, #a0aec0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Chart */
.systasks-chart-wrap {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.systasks-chart-wrap canvas {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

/* Section titles */
.systasks-section-title {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #a0aec0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Empty state */
.systasks-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 16px;
    color: rgba(255, 255, 255, 0.15);
    font-size: 13px;
}

/* Task list */
.systasks-list {
    padding: 4px 12px 12px;
    overflow-y: auto;
    max-height: 300px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
.systasks-list::-webkit-scrollbar-track { background: transparent; }
.systasks-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #06b6d4, rgba(6, 182, 212, 0.5));
    border: 2px solid rgba(12, 14, 20, 0.96);
    border-radius: 0;
}
::-webkit-scrollbar-button { display: none !important; }

.systasks-history {
    max-height: 200px;
}

/* Task card */
.systasks-task {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.systasks-task.active {
    background: rgba(6, 182, 212, 0.04);
    border-color: rgba(6, 182, 212, 0.12);
}

.systasks-task:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Task header */
.systasks-task-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.systasks-task-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(6, 182, 212, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.systasks-task-info {
    flex: 1;
    min-width: 0;
}

.systasks-task-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #f0f0f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.systasks-task-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 11px;
}

.systasks-task-status {
    font-weight: 600;
}

.systasks-task-app {
    color: var(--text-secondary, #a0aec0);
    opacity: 0.7;
}

.systasks-task-time {
    color: var(--text-secondary, #a0aec0);
    opacity: 0.5;
    font-variant-numeric: tabular-nums;
}

.systasks-task-cancel {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    transition: background 0.15s;
    user-select: none;
}

.systasks-task-cancel:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Progress bar */
.systasks-task-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.systasks-task-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.systasks-task-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px currentColor;
}

.systasks-task-pct {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #a0aec0);
    font-variant-numeric: tabular-nums;
    min-width: 32px;
    text-align: right;
}

.systasks-task-detail {
    font-size: 11px;
    color: var(--text-secondary, #a0aec0);
    margin-top: 4px;
    opacity: 0.7;
}

.systasks-task-error {
    font-size: 11px;
    color: #ef4444;
    margin-top: 4px;
    opacity: 0.8;
}

/* Light theme */
[data-theme="light"] .systasks-panel {
    background: #ffffff;
    border: 1px solid #d1d5db;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.08);
    backdrop-filter: none;
}

[data-theme="light"] .systasks-header {
    border-bottom: 1px solid #e5e7eb;
}

[data-theme="light"] .systasks-title {
    color: #111827;
}

[data-theme="light"] .systasks-close {
    background: #f3f4f6;
    color: #374151;
}

[data-theme="light"] .systasks-close:hover {
    background: #e5e7eb;
    color: #111827;
}

[data-theme="light"] .systasks-stats {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

[data-theme="light"] .systasks-counter-label {
    color: #374151;
    font-weight: 700;
}

[data-theme="light"] .systasks-chart-wrap {
    border-bottom: 1px solid #e5e7eb;
}

[data-theme="light"] .systasks-chart-wrap canvas {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

[data-theme="light"] .systasks-section-title {
    color: #111827;
}

[data-theme="light"] .systasks-task {
    background: #f9fafb;
    border-color: #d1d5db;
}

[data-theme="light"] .systasks-task:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

[data-theme="light"] .systasks-task.active {
    background: #ecfeff;
    border-color: #06b6d4;
}

[data-theme="light"] .systasks-task-name {
    color: #111827;
}

[data-theme="light"] .systasks-task-app,
[data-theme="light"] .systasks-task-time {
    color: #4b5563;
    opacity: 1;
}

[data-theme="light"] .systasks-task-detail,
[data-theme="light"] .systasks-task-pct {
    color: #4b5563;
    opacity: 1;
}

[data-theme="light"] .systasks-task-bar {
    background: #d1d5db;
}

[data-theme="light"] .systasks-task-icon {
    background: #ecfeff;
}

[data-theme="light"] .systasks-task-cancel {
    background: #fef2f2;
}

[data-theme="light"] .systasks-task-cancel:hover {
    background: #fee2e2;
}

[data-theme="light"] .systasks-task-error {
    color: #dc2626;
    opacity: 1;
}

[data-theme="light"] .systasks-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .systasks-btn.active {
    background: #ecfeff;
}

[data-theme="light"] .systasks-empty {
    color: #6b7280;
}

[data-theme="light"] .systasks-list::-webkit-scrollbar-track {
    background: #f9fafb;
}

[data-theme="light"] .systasks-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #06b6d4, rgba(6, 182, 212, 0.6));
    border-color: #ffffff;
}

/* Responsive */
@media (max-width: 480px) {
    .systasks-panel {
        width: calc(100vw - 16px);
        right: 8px;
        left: 8px;
    }
}
