/* ===================================
   SKELETON LOADING & ANIMATIONS
   Treningslogg v2.0
   =================================== */

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

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes checkDraw {
    0% { stroke-dashoffset: 24; }
    100% { stroke-dashoffset: 0; }
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes saveSuccessAnim {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 0 12px rgba(16, 185, 129, 0.6); }
}

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

@keyframes notificationBounce {
    0% { transform: translateX(120%); opacity: 0; }
    60% { transform: translateX(-8px); opacity: 1; }
    80% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* --- Skeleton Base --- */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-secondary) 25%,
        var(--bg-hover, #f0f0f0) 50%,
        var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm, 6px);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long { width: 90%; }

.skeleton-card {
    height: 120px;
    border-radius: var(--radius-md, 10px);
    margin-bottom: 1rem;
}

.skeleton-chart {
    height: 200px;
    border-radius: var(--radius-md, 10px);
}

.skeleton-value {
    height: 2.5rem;
    width: 80px;
    border-radius: 6px;
    display: inline-block;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* --- Staggered Page Load --- */
.stagger-in {
    opacity: 0;
    transform: translateY(16px);
}

.stagger-in.visible {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-in:nth-child(1) { animation-delay: 0ms; }
.stagger-in:nth-child(2) { animation-delay: 60ms; }
.stagger-in:nth-child(3) { animation-delay: 120ms; }
.stagger-in:nth-child(4) { animation-delay: 180ms; }
.stagger-in:nth-child(5) { animation-delay: 240ms; }
.stagger-in:nth-child(6) { animation-delay: 300ms; }
.stagger-in:nth-child(7) { animation-delay: 360ms; }
.stagger-in:nth-child(8) { animation-delay: 420ms; }
.stagger-in:nth-child(9) { animation-delay: 480ms; }
.stagger-in:nth-child(10) { animation-delay: 540ms; }
.stagger-in:nth-child(11) { animation-delay: 600ms; }
.stagger-in:nth-child(12) { animation-delay: 660ms; }

/* --- Tab Crossfade --- */
.tab-content {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-content.active {
    opacity: 1;
    transform: translateY(0);
}

.tab-content.fade-out {
    opacity: 0;
    transform: translateY(-8px);
}

/* --- Date Navigation Slide --- */
.daily-content-wrapper {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.daily-content-wrapper.slide-out-left {
    opacity: 0;
    transform: translateX(-30px);
}

.daily-content-wrapper.slide-out-right {
    opacity: 0;
    transform: translateX(30px);
}

.daily-content-wrapper.slide-in-left {
    animation: slideInLeft 0.3s ease forwards;
}

.daily-content-wrapper.slide-in-right {
    animation: slideInRight 0.3s ease forwards;
}

/* --- Button Micro-interactions --- */
button, .save-button, .export-button, .quick-entry-toggle {
    position: relative;
    overflow: hidden;
}

button:active, .save-button:active, .export-button:active {
    transform: scale(0.96) !important;
    transition: transform 0.1s ease !important;
}

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

/* Save success state */
.save-button.save-success {
    background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%) !important;
    animation: saveSuccessAnim 0.4s ease;
}

.save-button.save-success .checkmark-icon {
    display: inline-block;
    animation: scaleIn 0.3s ease;
}

/* --- Custom Checkbox Animation --- */
.animated-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-dark, #d0d0d0);
    border-radius: 6px;
    background: var(--bg-tertiary, #fff);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    flex-shrink: 0;
}

.animated-checkbox:hover {
    border-color: var(--primary, #1a3a52);
    box-shadow: 0 0 0 3px rgba(26, 58, 82, 0.1);
}

.animated-checkbox:checked {
    background: var(--primary, #1a3a52);
    border-color: var(--primary, #1a3a52);
}

.animated-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 6px;
    width: 6px;
    height: 10px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
    animation: scaleIn 0.2s ease;
}

/* --- Form Field Focus Enhancement --- */
input:focus, select:focus, textarea:focus {
    border-color: var(--primary, #1a3a52) !important;
    box-shadow: 0 0 0 3px rgba(26, 58, 82, 0.12) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

/* --- Progress Bar Glow --- */
.progress-bar-fill, .progress-fill {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.progress-bar-fill.glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* --- Counter Animation --- */
.counter-animate {
    animation: countUp 0.4s ease forwards;
}

/* --- Notification Bounce --- */
.notification.bounce-in {
    animation: notificationBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Section Collapse/Expand --- */
.section.collapsible .section-content {
    max-height: 5000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.section.collapsible.collapsed .section-content {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.section .section-header {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.section .section-header:hover {
    background-color: var(--bg-hover, #f8f8f8);
    border-radius: var(--radius-md, 10px);
}

/* Collapse indicator arrow */
.section.collapsible .section-header::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-secondary, #666);
    border-bottom: 2px solid var(--text-secondary, #666);
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.section.collapsible.collapsed .section-header::after {
    transform: rotate(-135deg);
}

/* --- Glassmorphism Cards (Del 6) --- */
.dashboard-card.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .dashboard-card.glass {
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Dashboard Gradient Background --- */
.dashboard-gradient {
    background: linear-gradient(135deg,
        var(--bg-primary, #fafafa) 0%,
        var(--bg-secondary, #f5f5f5) 50%,
        var(--bg-primary, #fafafa) 100%);
    border-radius: var(--radius-lg, 16px);
    padding: var(--space-xl, 2rem);
}

/* --- Enhanced Card Hover --- */
.dashboard-card,
.stat-card,
.section {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.12));
}

.stat-card:hover {
    transform: translateY(-2px) scale(1.01);
}

/* --- Auto-filled Field Indicator --- */
.auto-filled {
    background-color: #e3f2fd !important;
    transition: background-color 0.3s ease;
}

[data-theme="dark"] .auto-filled {
    background-color: rgba(33, 150, 243, 0.15) !important;
}

/* --- Loading State for Dashboard Values --- */
.dashboard-value.loading {
    color: transparent;
    position: relative;
}

.dashboard-value.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: linear-gradient(90deg,
        var(--bg-secondary) 25%,
        var(--bg-hover, #f0f0f0) 50%,
        var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
