/* Custom Styles - Complementing Tailwind CSS */
/* Enhanced UX with modern animations and micro-interactions */

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

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

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

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

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(79, 70, 229, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(79, 70, 229, 0.5);
    }
}

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

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

.animate-slide-in {
    animation: slide-in-right 0.5s ease-out;
}

.animate-scale-in {
    animation: scale-in 0.4s ease-out;
}

/* Form Steps */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: scale-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Glassmorphism effect for containers */
#form-container,
#routine-container > div {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(79, 70, 229, 0.1);
}

/* Duration Pills */
.duration-pill,
.chronotype-pill,
.season-pill,
.fitness-pill,
.equipment-pill {
    padding: 0.75rem 1rem;
    border: 2px solid #E5E7EB;
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 500;
    color: #4B5563;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.duration-pill::before,
.chronotype-pill::before,
.season-pill::before,
.fitness-pill::before,
.equipment-pill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.duration-pill:hover,
.chronotype-pill:hover,
.season-pill:hover,
.fitness-pill:hover,
.equipment-pill:hover {
    border-color: #4F46E5;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.3);
}

.duration-pill:hover::before,
.chronotype-pill:hover::before,
.season-pill:hover::before,
.fitness-pill:hover::before,
.equipment-pill:hover::before {
    opacity: 1;
}

.duration-pill.active,
.chronotype-pill.active,
.season-pill.active,
.fitness-pill.active,
.equipment-pill.active {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    border-color: #4F46E5;
    transform: scale(1.05);
    box-shadow: 0 8px 16px -4px rgba(79, 70, 229, 0.4);
}

.duration-pill:active,
.chronotype-pill:active,
.season-pill:active,
.fitness-pill:active,
.equipment-pill:active {
    transform: scale(0.98);
}

/* Goal Checkboxes */
.goal-checkbox {
    position: relative;
    display: block;
    cursor: pointer;
}

.goal-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.goal-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid #E5E7EB;
    border-radius: 0.75rem;
    background: white;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.goal-label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.goal-checkbox:hover .goal-label {
    border-color: #4F46E5;
    transform: translateX(5px);
    box-shadow: 0 8px 16px -4px rgba(79, 70, 229, 0.2);
}

.goal-checkbox input[type="checkbox"]:checked + .goal-label {
    background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
    border-color: #4F46E5;
    font-weight: 600;
    transform: translateX(5px);
}

.goal-checkbox input[type="checkbox"]:checked + .goal-label::before {
    transform: scaleY(1);
}

.goal-label span:first-child {
    transition: transform 0.3s ease;
}

.goal-checkbox input[type="checkbox"]:checked + .goal-label span:first-child {
    transform: scale(1.2);
}

/* Buttons */
.btn-primary {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    font-weight: 600;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary:disabled:hover::before {
    left: -100%;
}

.btn-secondary {
    padding: 1rem 2rem;
    background: white;
    color: #4F46E5;
    font-weight: 600;
    border: 2px solid #4F46E5;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #F5F3FF;
    transform: translateY(-2px);
}

.btn-export {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.btn-export::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.btn-export:hover::before {
    width: 300px;
    height: 300px;
}

.btn-export:hover {
    border-color: #4F46E5;
    background: transparent;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 16px -4px rgba(79, 70, 229, 0.3);
    color: #4F46E5;
}

.btn-export:active {
    transform: translateY(-1px) scale(0.98);
}

/* Timeline Activity Cards */
.activity-card {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 1rem;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: slide-in-right 0.5s ease-out forwards;
}

.activity-card:nth-child(1) { animation-delay: 0.1s; }
.activity-card:nth-child(2) { animation-delay: 0.2s; }
.activity-card:nth-child(3) { animation-delay: 0.3s; }
.activity-card:nth-child(4) { animation-delay: 0.4s; }
.activity-card:nth-child(5) { animation-delay: 0.5s; }
.activity-card:nth-child(6) { animation-delay: 0.6s; }

.activity-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.activity-card:hover {
    border-color: #4F46E5;
    box-shadow: 0 12px 24px -8px rgba(79, 70, 229, 0.3);
    transform: translateX(10px) scale(1.02);
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
}

.activity-card:hover::before {
    transform: scaleY(1);
}

.activity-card:active {
    transform: translateX(8px) scale(1);
}

.activity-time {
    flex-shrink: 0;
    width: 80px;
    font-weight: 700;
    color: #4F46E5;
    font-size: 0.875rem;
}

.activity-duration {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #F3F4F6;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 700;
    color: #111827;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.activity-description {
    color: #6B7280;
    font-size: 0.875rem;
    line-height: 1.5;
}

.activity-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

/* Rate Limit Warning */
.rate-limit-warning {
    padding: 1rem;
    background: #FEF3C7;
    border: 2px solid #F59E0B;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    animation: fade-in 0.5s ease-out;
}

.rate-limit-error {
    padding: 1rem;
    background: #FEE2E2;
    border: 2px solid #EF4444;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    animation: fade-in 0.5s ease-out;
}

/* Loading State */
.btn-loader svg {
    margin-right: 0.5rem;
}

/* Success Badge */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
    animation: scale-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.ai-badge span:first-child {
    animation: pulse-glow 2s ease-in-out infinite;
}

.fallback-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: white;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
    animation: scale-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .activity-card {
        flex-direction: column;
    }
    
    .activity-time {
        width: auto;
    }
}

/* Print Styles for PDF Export */
@media print {
    header,
    footer,
    .btn-export,
    button {
        display: none;
    }
    
    body {
        background: white;
    }
    
    #routine-container {
        box-shadow: none;
        border: 1px solid #E5E7EB;
    }
}

/* Progress Bar Enhancement */
#progress-bar {
    background: linear-gradient(90deg, #4F46E5 0%, #7C3AED 100%);
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

#progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 2s infinite;
}

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

/* Focus States for Accessibility */
button:focus,
input:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
    border-color: #4F46E5;
}

input[type="time"]:focus {
    transform: scale(1.02);
    transition: all 0.3s ease;
}

/* Floating Label Effect */
input[type="time"] {
    transition: all 0.3s ease;
}

input[type="time"]:hover {
    border-color: #4F46E5;
    box-shadow: 0 4px 8px -2px rgba(79, 70, 229, 0.2);
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: #111827;
    color: white;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    margin-bottom: 0.5rem;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Loading skeleton animation */
@keyframes skeleton-loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.5rem;
}

/* Confetti effect for success */
@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #4F46E5;
    top: -10px;
    animation: confetti-fall 3s linear;
    pointer-events: none;
    z-index: 9999;
}

/* Enhanced header with sticky shadow */
header {
    transition: box-shadow 0.3s ease;
}

header.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Floating animation for hero badges */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

/* Gradient text animation */
@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.animate-gradient {
    background-size: 200% auto;
    animation: gradient-shift 3s ease infinite;
}

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

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Time input enhancement */
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(47%) sepia(96%) saturate(3333%) hue-rotate(234deg) brightness(92%) contrast(92%);
}

/* Checkbox enhancement */
input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #4F46E5;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}

input[type="checkbox"]:checked::before {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

input[type="checkbox"]:checked {
    background: #4F46E5;
}

/* Smooth page transitions */
body {
    transition: background-color 0.3s ease;
}

/* Loading spinner enhancement */
@keyframes spin-scale {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

.animate-spin {
    animation: spin-scale 1s linear infinite;
}

/* Animated blob background */
@keyframes blob {
    0%, 100% {
        transform: translate(0px, 0px) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.animate-blob {
    animation: blob 7s infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

/* Smooth transitions for all interactive elements */
button, a, input, select, .duration-pill, .chronotype-pill, 
.season-pill, .fitness-pill, .equipment-pill, .goal-checkbox {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Better mobile touch feedback */
@media (hover: none) {
    button:active, .duration-pill:active, .chronotype-pill:active,
    .season-pill:active, .fitness-pill:active, .equipment-pill:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}
