/* ========================================
   PHASE 1: GLASSMORPHISM & VISUAL EFFECTS
   ======================================== */

/* Glassmorphism Card Base */
.glass-card {
    background: rgba(var(--surface-1-rgb, 20, 22, 26), 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    background: rgba(var(--surface-1-rgb, 20, 22, 26), 0.85);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

/* Apply glassmorphism to bento widgets */
.bento-widget {
    background: rgba(var(--surface-1-rgb, 20, 22, 26), 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bento-widget:hover {
    background: rgba(var(--surface-1-rgb, 20, 22, 26), 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transform: translateY(-3px);
}

/* Light theme adjustments for glassmorphism */
[data-theme="light"] .bento-widget,
[data-theme="snow"] .bento-widget,
[data-theme="latte"] .bento-widget {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .bento-widget:hover,
[data-theme="snow"] .bento-widget:hover,
[data-theme="latte"] .bento-widget:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Shimmer loading effect */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.shimmer {
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Circular Progress Ring */
.progress-ring {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.progress-ring svg {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-ring-bg {
    stroke: var(--surface-3);
}

.progress-ring-value {
    position: absolute;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-ring-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* Sparkline Container */
.sparkline-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sparkline {
    width: 60px;
    height: 24px;
}

.sparkline-path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-area {
    opacity: 0.2;
}

.sparkline-positive {
    stroke: var(--success);
}
.sparkline-positive .sparkline-area {
    fill: var(--success);
}

.sparkline-negative {
    stroke: var(--error);
}
.sparkline-negative .sparkline-area {
    fill: var(--error);
}

.sparkline-neutral {
    stroke: var(--brand-red);
}
.sparkline-neutral .sparkline-area {
    fill: var(--brand-red);
}

/* Stat item with sparkline */
.stat-with-sparkline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
}

.stat-with-sparkline .stat-info {
    flex: 1;
}

.stat-with-sparkline .stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-with-sparkline .stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.stat-with-sparkline .stat-change {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-left: var(--space-2);
}

.stat-change.positive {
    background: var(--success-muted);
    color: var(--success);
}

.stat-change.negative {
    background: var(--error-muted);
    color: var(--error);
}

/* Mini Heatmap */
.mini-heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    padding: var(--space-2);
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    transition: transform 0.15s;
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.heatmap-cell.level-0 { background: var(--surface-3); opacity: 0.3; }
.heatmap-cell.level-1 { background: var(--brand-red); opacity: 0.25; }
.heatmap-cell.level-2 { background: var(--brand-red); opacity: 0.45; }
.heatmap-cell.level-3 { background: var(--brand-red); opacity: 0.65; }
.heatmap-cell.level-4 { background: var(--brand-red); opacity: 0.85; }
.heatmap-cell.level-5 { background: var(--brand-red); opacity: 1; }

/* Heatmap tooltip */
.heatmap-tooltip {
    position: absolute;
    background: var(--surface-overlay);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: 11px;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Activity Heatmap specific */
.activity-heatmap {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 1px;
    height: 60px;
}

.activity-heatmap-cell {
    background: var(--surface-3);
    border-radius: 1px;
    transition: background 0.2s;
}

.activity-heatmap-cell.active {
    background: var(--brand-red);
}

/* Enhanced Quick Stats */
.quick-stats-enhanced {
    display: flex;
    gap: var(--space-2);
    align-items: stretch;
}

.quick-stat-card {
    flex: 1;
    min-width: 0;
    background: rgba(var(--surface-2-rgb, 28, 30, 35), 0.5);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 0.2s;
}

.quick-stat-card:hover {
    background: rgba(var(--surface-2-rgb, 28, 30, 35), 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Fade-in animation for widgets */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.widget-fade-in {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Stagger children animations */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }

/* ========================================
   PHASE 2 & 3: MOTION & WIDGET ENHANCEMENTS
   ======================================== */

/* Snap animation for drag-drop */
@keyframes snapIn {
    0% {
        transform: scale(0.92) translateY(-8px);
        opacity: 0;
    }
    60% {
        transform: scale(1.01) translateY(2px);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Enhanced widget transitions */
.bento-widget {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

/* Enhanced hover lift with glassmorphism */
.bento-widget:hover {
    transform: translateY(-4px);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Active/dragging state */
.bento-widget.widget-active {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.25),
        0 6px 16px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Content update pulse */
@keyframes contentPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.widget-content-updating {
    animation: contentPulse 0.5s ease-in-out;
}

/* Enhanced task card animations */
.task-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.task-card.dragging {
    opacity: 0.4;
    transform: scale(0.95) rotate(2deg);
    cursor: grabbing;
}

/* Enhanced shimmer effect */
.shimmer-glass {
    background: linear-gradient(
        90deg,
        rgba(var(--surface-2-rgb, 28, 30, 35), 0.8) 25%,
        rgba(var(--surface-3-rgb, 38, 40, 46), 0.9) 50%,
        rgba(var(--surface-2-rgb, 28, 30, 35), 0.8) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-md);
    backdrop-filter: blur(4px);
}

/* Focus mode backdrop */
.focus-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.focus-mode .focus-backdrop {
    opacity: 1;
}

/* Widget resize handle with glassmorphism */
.widget-resize-handle {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: linear-gradient(135deg, transparent 50%, rgba(var(--text-muted-rgb, 150, 150, 150), 0.5) 50%);
    border-radius: 0 0 var(--radius-md) 0;
}

.bento-widget:hover .widget-resize-handle {
    opacity: 0.6;
}

.widget-resize-handle:hover {
    opacity: 1 !important;
}

/* Drop zone enhancement */
.drop-zone {
    transition: background-color 0.2s ease, 
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

.drop-zone.drag-over {
    background-color: rgba(var(--brand-red-rgb, 188, 32, 38), 0.06);
    border: 2px dashed rgba(var(--brand-red-rgb, 188, 32, 38), 0.4);
    box-shadow: inset 0 0 30px rgba(var(--brand-red-rgb, 188, 32, 38), 0.08);
}

/* Widget controls glassmorphism */
.widget-controls {
    display: flex;
    gap: 4px;
}

.widget-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(var(--surface-2-rgb, 28, 30, 35), 0.6);
    backdrop-filter: blur(4px);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.widget-btn:hover {
    background: rgba(var(--surface-3-rgb, 38, 40, 46), 0.8);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Light theme adjustments */
[data-theme="light"] .bento-widget:hover,
[data-theme="snow"] .bento-widget:hover,
[data-theme="latte"] .bento-widget:hover {
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .task-card:hover,
[data-theme="snow"] .task-card:hover,
[data-theme="latte"] .task-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}
