/* Base Animations */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes pulse-subtle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

@keyframes cell-check {
    0% { transform: scale(1); }
    50% { transform: scale(0.85) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes float-slow {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(2deg); }
    66% { transform: translate(-20px, 20px) rotate(-2deg); }
}

@keyframes float-medium {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(0, -10px); }
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes ripple {
    0% { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.animate-fade-in {
    animation: fade-in 0.6s ease-out forwards;
}

.animate-slide-up {
    animation: slide-up 0.6s ease-out forwards;
    opacity: 0;
}

.animate-float-slow {
    animation: float-slow 20s ease-in-out infinite;
}

.animate-float-medium {
    animation: float-medium 6s ease-in-out infinite;
}

.animate-pulse-glow {
    animation: pulse-glow 4s ease-in-out infinite;
}

/* Improved Scrollbar for Dark Mode */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Custom Selection Color */
::selection {
    background: rgba(99, 102, 241, 0.4);
    color: white;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* Glass Effect - Dark Mode */
.glass {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Habit Grid Specifics - Dark Mode with Glow Effects */
.habit-grid {
    display: grid;
    gap: 8px;
}

.habit-cell {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.5);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.habit-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.habit-cell:hover {
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 40px rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.6);
    z-index: 10;
}

.habit-cell:hover::before {
    opacity: 1;
}

.habit-cell.active {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-color: rgba(99, 102, 241, 0.8);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5), inset 0 1px 0 rgba(255,255,255,0.2);
    animation: cell-glow 2s ease-in-out infinite;
}

@keyframes cell-glow {
    0%, 100% { box-shadow: 0 0 15px rgba(99, 102, 241, 0.5), inset 0 1px 0 rgba(255,255,255,0.2); }
    50% { box-shadow: 0 0 25px rgba(168, 85, 247, 0.6), inset 0 1px 0 rgba(255,255,255,0.2); }
}

.habit-cell.active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    border-radius: inherit;
}

.habit-cell.animating {
    animation: cell-check 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.habit-cell.today {
    border-color: #6366f1;
    border-width: 2px;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
    50% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4); }
}

/* Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.6);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

/* Habit Row Styling - Dark Mode */
.habit-row {
    display: contents;
}

.habit-label {
    position: sticky;
    left: 0;
    background: linear-gradient(90deg, #0f172a 0%, #0f172a 85%, transparent 100%);
    z-index: 20;
    padding-right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
}

.habit-label::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent, rgba(99, 102, 241, 0.3), transparent);
}

/* Sidebar Item Animations - Enhanced */
.habit-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slide-in-right 0.4s ease-out backwards;
}

.habit-item:hover {
    background-color: rgba(99, 102, 241, 0.1);
    transform: translateX(8px);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Tooltip - Dark Mode */
#tooltip {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

/* Input Focus Effects - Dark Mode */
input:focus {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Chart Container */
canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Mobile Optimizations */
@media (max-width: 1024px) {
    .habit-cell {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .habit-label {
        min-width: 140px;
        max-width: 140px;
    }
    
    .habit-grid {
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .habit-cell {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}

/* Streak Animation - Enhanced */
.streak-badge {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #0f172a;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
    animation: pulse-subtle 2s ease-in-out infinite;
}

/* Stagger Animation for Grid Items */
.habit-cell {
    animation: fade-in 0.4s ease-out backwards;
}

/* Responsive adjustments for touch */
@media (hover: none) {
    .habit-cell:hover {
        transform: scale(1.05);
    }
    
    .habit-cell.active {
        animation: none;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}