/* ============================================
   ANIMATIONS & TRANSITIONS
   ============================================ */

/* Global transition defaults */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   ONBOARDING FLOW
   ============================================ */

.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.onboarding-overlay.visible {
    opacity: 1;
}

.onboarding-container {
    width: 90%;
    max-width: 500px;
    text-align: center;
    color: white;
    padding: 20px;
}

.onboarding-slides {
    position: relative;
    min-height: 400px;
}

.onboarding-slide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.4s ease;
    pointer-events: none;
}

.onboarding-slide.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.onboarding-icon {
    font-size: 80px;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

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

.onboarding-slide h1 {
    font-size: 28px;
    margin-bottom: 16px;
    font-weight: 700;
}

.onboarding-slide p {
    font-size: 16px;
    opacity: 0.9;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Habit selection chips */
.onboarding-habits {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.onboarding-habit-chip {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 16px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.onboarding-habit-chip:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.onboarding-habit-chip.selected {
    background: white;
    color: #667eea;
    border-color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.onboarding-habit-chip.selected:hover {
    transform: scale(1.05);
}

/* Progress dots */
.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
}

.onboarding-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.onboarding-dot.active {
    background: white;
    transform: scale(1.2);
}

.onboarding-dot:hover {
    background: rgba(255, 255, 255, 0.6);
}

/* Navigation buttons */
.onboarding-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.onboarding-skip {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    cursor: pointer;
    padding: 12px 24px;
    transition: color 0.2s;
}

.onboarding-skip:hover {
    color: white;
}

.onboarding-next {
    background: white;
    color: #667eea;
    border: none;
    padding: 14px 32px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.onboarding-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ============================================
   CHECK ANIMATION
   ============================================ */

.check-animation {
    position: relative;
    overflow: hidden;
}

.check-animation::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 24px;
    color: var(--primary-color);
    animation: checkPop 0.4s ease forwards;
    pointer-events: none;
}

@keyframes checkPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* Ripple effect on click */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: var(--ripple-y, 50%);
    left: var(--ripple-x, 50%);
    width: 0;
    height: 0;
    background: rgba(76, 175, 80, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: rippleEffect 0.6s ease-out forwards;
}

@keyframes rippleEffect {
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* ============================================
   TABLE CELL ANIMATIONS
   ============================================ */

#habit-table td.clickable-cell {
    transition: all 0.15s ease;
    position: relative;
}

#habit-table td.tracked-cell {
    animation: cellTrack 0.3s ease;
}

@keyframes cellTrack {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Success pulse for tracked cells */
.cell-success {
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5);
    }
    100% {
        box-shadow: 0 0 0 15px rgba(76, 175, 80, 0);
    }
}

/* ============================================
   HABIT ITEM ANIMATIONS
   ============================================ */

.habit-item {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for list items */
.habit-item:nth-child(1) { animation-delay: 0.0s; }
.habit-item:nth-child(2) { animation-delay: 0.05s; }
.habit-item:nth-child(3) { animation-delay: 0.1s; }
.habit-item:nth-child(4) { animation-delay: 0.15s; }
.habit-item:nth-child(5) { animation-delay: 0.2s; }
.habit-item:nth-child(6) { animation-delay: 0.25s; }
.habit-item:nth-child(7) { animation-delay: 0.3s; }
.habit-item:nth-child(8) { animation-delay: 0.35s; }
.habit-item:nth-child(9) { animation-delay: 0.4s; }
.habit-item:nth-child(10) { animation-delay: 0.45s; }

/* Track button animation */
.track-btn {
    transition: all 0.2s ease;
}

.track-btn:active {
    transform: scale(0.95);
}

.track-btn.tracked {
    animation: trackComplete 0.4s ease;
}

@keyframes trackComplete {
    0% { transform: scale(1); }
    30% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ============================================
   VIEW TRANSITIONS
   ============================================ */

#settings-view, #table-view, #history-view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   MODAL ANIMATIONS
   ============================================ */

.modal {
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   BUTTON HOVER EFFECTS
   ============================================ */

button {
    transition: all 0.2s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* ============================================
   SUMMARY CARDS ANIMATION
   ============================================ */

.summary-card {
    animation: cardFloat 0.5s ease;
}

.summary-card:nth-child(1) { animation-delay: 0.0s; }
.summary-card:nth-child(2) { animation-delay: 0.1s; }
.summary-card:nth-child(3) { animation-delay: 0.2s; }

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

/* ============================================
   HEATMAP CELL ANIMATION
   ============================================ */

.heatmap-cell {
    animation: heatmapFade 0.3s ease;
    animation-fill-mode: both;
}

.heatmap-grid .heatmap-cell:nth-child(1) { animation-delay: 0.01s; }
.heatmap-grid .heatmap-cell:nth-child(2) { animation-delay: 0.02s; }
.heatmap-grid .heatmap-cell:nth-child(3) { animation-delay: 0.03s; }
.heatmap-grid .heatmap-cell:nth-child(4) { animation-delay: 0.04s; }
.heatmap-grid .heatmap-cell:nth-child(5) { animation-delay: 0.05s; }
.heatmap-grid .heatmap-cell:nth-child(6) { animation-delay: 0.06s; }
.heatmap-grid .heatmap-cell:nth-child(7) { animation-delay: 0.07s; }

@keyframes heatmapFade {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   TEMPLATE CHIP ANIMATION
   ============================================ */

.template-habit {
    animation: chipFade 0.3s ease;
    animation-fill-mode: both;
}

@keyframes chipFade {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   LOADING SPINNER (for future use)
   ============================================ */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 767px) {
    .onboarding-icon {
        font-size: 60px;
    }

    .onboarding-slide h1 {
        font-size: 24px;
    }

    .onboarding-slides {
        min-height: 350px;
    }

    .onboarding-habit-chip {
        padding: 8px 12px;
        font-size: 13px;
    }
}
