/* ========================================
   Micro-Interactions & Animation System
   ======================================== */

/* ----------------------------------------
   CSS Custom Properties for Animations
   ---------------------------------------- */
:root {
    /* Timing Functions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    
    /* Durations */
    --duration-instant: 75ms;
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
    --duration-slower: 600ms;
}

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

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

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

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

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

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

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

/* Stagger delay classes */
.animate-stagger-1 { animation-delay: 50ms; }
.animate-stagger-2 { animation-delay: 100ms; }
.animate-stagger-3 { animation-delay: 150ms; }
.animate-stagger-4 { animation-delay: 200ms; }
.animate-stagger-5 { animation-delay: 250ms; }
.animate-stagger-6 { animation-delay: 300ms; }
.animate-stagger-7 { animation-delay: 350ms; }
.animate-stagger-8 { animation-delay: 400ms; }

/* Animation utility classes */
.animate-fade-in-up {
    animation: fadeInUp var(--duration-slow) var(--ease-out-expo) both;
}

.animate-fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out-quart) both;
}

.animate-scale-in {
    animation: scaleIn var(--duration-normal) var(--ease-out-expo) both;
}

.animate-slide-in-right {
    animation: slideInRight var(--duration-slow) var(--ease-out-expo) both;
}

.animate-slide-in-left {
    animation: slideInLeft var(--duration-slow) var(--ease-out-expo) both;
}

.animate-slide-in-down {
    animation: slideInDown var(--duration-slow) var(--ease-out-expo) both;
}

/* ----------------------------------------
   Button Interactions
   ---------------------------------------- */

/* Enhanced button press effect */
.btn,
.btn-primary,
.btn-secondary,
.action-btn,
.quick-btn,
.day-btn,
.choose-btn,
.tab-btn,
.review-btn,
.mark-paid-btn,
.apply-credit-btn,
.credit-request-btn,
.filter-reset-btn {
    position: relative;
    overflow: hidden;
    transform: translateZ(0); /* Hardware acceleration */
    transition: 
        transform var(--duration-fast) var(--ease-out-quart),
        background-color var(--duration-normal) var(--ease-out-quart),
        box-shadow var(--duration-normal) var(--ease-out-quart),
        border-color var(--duration-normal) var(--ease-out-quart);
}

.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.action-btn:hover,
.quick-btn:hover,
.review-btn:hover,
.mark-paid-btn:hover,
.apply-credit-btn:hover,
.credit-request-btn:hover {
    transform: translateY(-1px);
}

.btn:active,
.btn-primary:active,
.btn-secondary:active,
.action-btn:active,
.quick-btn:active,
.day-btn:active,
.choose-btn:active,
.tab-btn:active,
.review-btn:active,
.mark-paid-btn:active,
.apply-credit-btn:active,
.credit-request-btn:active,
.filter-reset-btn:active {
    transform: scale(0.97) translateY(0);
    transition-duration: var(--duration-instant);
}

/* Ripple effect for buttons */
.btn::after,
.btn-primary::after,
.btn-secondary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, currentColor 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: transform var(--duration-slow) var(--ease-out-expo), opacity var(--duration-slow);
    pointer-events: none;
}

.btn:active::after,
.btn-primary:active::after,
.btn-secondary:active::after {
    opacity: 0.1;
    transform: scale(2.5);
    transition-duration: 0ms;
}

/* Focus ring animation */
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.action-btn:focus-visible,
.quick-btn:focus-visible,
.day-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(190, 24, 93, 0.3);
    animation: focusRing var(--duration-normal) var(--ease-out-quart);
}

@keyframes focusRing {
    from {
        box-shadow: 0 0 0 0px rgba(190, 24, 93, 0.5);
    }
    to {
        box-shadow: 0 0 0 3px rgba(190, 24, 93, 0.3);
    }
}

/* ----------------------------------------
   Card Interactions
   ---------------------------------------- */
.profile-card,
.booking-panel,
.admin-section,
.invoice-card,
.teacher-card,
.booking-card,
.credit-request-card,
.stat-item,
.summary-card,
.availability-grid-container {
    transition: 
        transform var(--duration-normal) var(--ease-out-quart),
        box-shadow var(--duration-normal) var(--ease-out-quart),
        border-color var(--duration-normal) var(--ease-out-quart);
}

/* Lift effect on hover */
.teacher-card:hover,
.booking-card:hover,
.credit-request-card:hover,
.invoice-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Subtle scale on selection */
.teacher-card.selected {
    transform: scale(1.02);
}

/* ----------------------------------------
   Form Input Interactions
   ---------------------------------------- */
.form-input,
.search-input,
.filter-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea {
    transition: 
        border-color var(--duration-normal) var(--ease-out-quart),
        box-shadow var(--duration-normal) var(--ease-out-quart),
        background-color var(--duration-normal) var(--ease-out-quart),
        transform var(--duration-fast) var(--ease-out-quart);
}

.form-input:focus,
.search-input:focus,
.filter-select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
textarea:focus {
    animation: inputFocus var(--duration-normal) var(--ease-out-quart);
}

@keyframes inputFocus {
    0% {
        box-shadow: 0 0 0 0px rgba(36, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(36, 99, 235, 0.2);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(36, 99, 235, 0.1);
    }
}

/* Label float effect (optional class) */
.form-group.floating-label {
    position: relative;
}

.form-group.floating-label .input-label {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    transition: 
        transform var(--duration-normal) var(--ease-out-quart),
        font-size var(--duration-normal) var(--ease-out-quart),
        color var(--duration-normal);
    pointer-events: none;
    background: var(--card-bg, #ffffff);
    padding: 0 4px;
}

.form-group.floating-label .form-input:focus ~ .input-label,
.form-group.floating-label .form-input:not(:placeholder-shown) ~ .input-label {
    transform: translateY(-2.2em);
    font-size: 12px;
    color: #2463eb;
}

/* ----------------------------------------
   Toggle/Switch Animations
   ---------------------------------------- */
.toggle-slider {
    transition: background-color var(--duration-normal) var(--ease-out-quart);
}

.toggle-slider::before {
    transition: 
        transform var(--duration-normal) var(--ease-spring),
        background-color var(--duration-normal);
}

.theme-toggle input:checked + .toggle-slider::before {
    animation: toggleBounce var(--duration-slow) var(--ease-spring);
}

@keyframes toggleBounce {
    0% { transform: translateX(0); }
    50% { transform: translateX(28px); }
    75% { transform: translateX(22px); }
    100% { transform: translateX(24px); }
}

/* ----------------------------------------
   Navigation Link Interactions
   ---------------------------------------- */
nav a,
.nav-link,
.text-link,
.login-link {
    position: relative;
    transition: 
        color var(--duration-fast) var(--ease-out-quart),
        opacity var(--duration-fast);
}

/* Underline animation for links */
.text-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

.text-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Sidebar nav link interactions */
.nav-link {
    transition: 
        background-color var(--duration-fast) var(--ease-out-quart),
        color var(--duration-fast),
        transform var(--duration-fast) var(--ease-out-quart);
}

.nav-link:hover {
    transform: translateX(4px);
}

.nav-link.active {
    animation: navActiveIn var(--duration-normal) var(--ease-out-expo);
}

@keyframes navActiveIn {
    from {
        background-color: transparent;
    }
}

/* Nav icon subtle animation */
.nav-icon {
    transition: transform var(--duration-fast) var(--ease-out-quart);
}

.nav-link:hover .nav-icon {
    transform: scale(1.1);
}

/* ----------------------------------------
   Modal Animations
   ---------------------------------------- */
.modal-overlay {
    transition: 
        opacity var(--duration-normal) var(--ease-out-quart),
        visibility var(--duration-normal);
}

.modal-content {
    transition: 
        transform var(--duration-slow) var(--ease-out-expo),
        opacity var(--duration-slow);
}

.modal-overlay.active .modal-content {
    animation: modalIn var(--duration-slow) var(--ease-out-expo);
}

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

.modal-close {
    transition: 
        transform var(--duration-fast) var(--ease-out-quart),
        background-color var(--duration-fast);
}

.modal-close:hover {
    transform: rotate(90deg);
}

/* ----------------------------------------
   Badge/Status Animations
   ---------------------------------------- */
.status-badge,
.role-badge,
.admin-badge {
    transition: 
        transform var(--duration-fast) var(--ease-out-quart),
        box-shadow var(--duration-fast);
}

.status-badge:hover,
.role-badge:hover,
.admin-badge:hover {
    transform: scale(1.05);
}

/* Pulse animation for pending status */
.status-badge.pending,
.status-dot.pending {
    animation: pulsePending 2s var(--ease-in-out-quart) infinite;
}

@keyframes pulsePending {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ----------------------------------------
   Banner/Alert Animations
   ---------------------------------------- */
.success-banner,
.error-banner,
.info-banner {
    animation: bannerSlideIn var(--duration-slow) var(--ease-out-expo);
}

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

/* Icon bounce in banners */
.success-banner svg,
.error-banner svg,
.info-banner svg {
    animation: iconBounce var(--duration-slower) var(--ease-spring);
}

@keyframes iconBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ----------------------------------------
   Table Row Interactions
   ---------------------------------------- */
.data-table tbody tr {
    transition: background-color var(--duration-fast) var(--ease-out-quart);
}

.data-table tbody tr:hover {
    position: relative;
}

.data-table tbody tr:hover::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #be185d;
    animation: tableRowHighlight var(--duration-normal) var(--ease-out-expo);
}

@keyframes tableRowHighlight {
    from {
        transform: scaleY(0);
    }
    to {
        transform: scaleY(1);
    }
}

/* ----------------------------------------
   Tab Transitions
   ---------------------------------------- */
.tab-btn {
    position: relative;
}

.tab-btn::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #be185d;
    transform: scaleX(0);
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

.tab-btn.active::before {
    transform: scaleX(1);
}

.tab-content {
    animation: tabContentFade var(--duration-normal) var(--ease-out-quart);
}

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

/* ----------------------------------------
   Avatar Interactions
   ---------------------------------------- */
.user-avatar,
.teacher-avatar,
.booking-teacher-avatar {
    transition: 
        transform var(--duration-fast) var(--ease-out-quart),
        box-shadow var(--duration-fast);
}

.teacher-card:hover .teacher-avatar,
.booking-card:hover .booking-teacher-avatar,
.request-user:hover .user-avatar {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ----------------------------------------
   Time Slot Interactions
   ---------------------------------------- */
.time-slot,
.slot-cell {
    transition: 
        transform var(--duration-fast) var(--ease-out-quart),
        background-color var(--duration-fast),
        border-color var(--duration-fast),
        box-shadow var(--duration-fast);
}

.time-slot:hover {
    transform: translateX(4px);
}

.slot-cell:not(.disabled):hover {
    transform: scale(1.05);
    z-index: 1;
}

.slot-cell.available {
    animation: slotSelect var(--duration-normal) var(--ease-spring);
}

@keyframes slotSelect {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ----------------------------------------
   Loading & Skeleton States
   ---------------------------------------- */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--hover-bg, #f3f4f6) 25%,
        var(--card-bg, #ffffff) 50%,
        var(--hover-bg, #f3f4f6) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--sidebar-border, #e5e7eb);
    border-top-color: #be185d;
    border-radius: 50%;
    animation: spin var(--duration-slower) linear infinite;
}

/* Button loading state */
.btn.loading,
.btn-primary.loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.btn.loading::before,
.btn-primary.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin var(--duration-slower) linear infinite;
    opacity: 0.8;
}

/* ----------------------------------------
   Checkbox & Radio Animations
   ---------------------------------------- */
input[type="checkbox"],
input[type="radio"] {
    transition: 
        transform var(--duration-fast) var(--ease-spring),
        box-shadow var(--duration-fast);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    animation: checkboxPop var(--duration-normal) var(--ease-spring);
}

@keyframes checkboxPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ----------------------------------------
   Tooltip Animations
   ---------------------------------------- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 6px 12px;
    background: #1f2937;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: 
        opacity var(--duration-fast) var(--ease-out-quart),
        transform var(--duration-fast) var(--ease-out-quart),
        visibility var(--duration-fast);
    pointer-events: none;
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
}

/* ----------------------------------------
   Grid Item Hover Effects
   ---------------------------------------- */
.grid-item {
    transition: transform var(--duration-normal) var(--ease-out-quart);
    overflow: hidden;
}

.grid-item:hover {
    transform: scale(1.02);
}

.grid-item img {
    transition: transform var(--duration-slow) var(--ease-out-quart);
}

.grid-item:hover img {
    transform: scale(1.1);
}

/* ----------------------------------------
   Logo Interaction
   ---------------------------------------- */
.logo {
    transition: transform var(--duration-normal) var(--ease-out-quart);
}

.logo:hover {
    transform: scale(1.05);
}

.logo-img {
    transition: filter var(--duration-normal);
}

/* ----------------------------------------
   Hero Section Animations
   ---------------------------------------- */
.hero h1 {
    animation: fadeInUp var(--duration-slower) var(--ease-out-expo) 100ms both;
}

.hero p {
    animation: fadeInUp var(--duration-slower) var(--ease-out-expo) 200ms both;
}

.hero .btn {
    animation: fadeInUp var(--duration-slower) var(--ease-out-expo) 300ms both;
}

/* ----------------------------------------
   Counter/Stat Animations
   ---------------------------------------- */
.stat-value,
.summary-count {
    transition: transform var(--duration-normal) var(--ease-out-quart);
}

.stat-item:hover .stat-value,
.summary-card:hover .summary-count {
    transform: scale(1.1);
}

/* ----------------------------------------
   Payment Option Interactions
   ---------------------------------------- */
.payment-option-label {
    transition: 
        border-color var(--duration-normal) var(--ease-out-quart),
        background-color var(--duration-normal),
        transform var(--duration-fast) var(--ease-out-quart);
}

.payment-option-label:hover {
    transform: translateY(-2px);
}

.payment-option input:checked + .payment-option-label {
    animation: optionSelect var(--duration-normal) var(--ease-spring);
}

@keyframes optionSelect {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* ----------------------------------------
   Mobile Menu Animations
   ---------------------------------------- */
.mobile-menu-btn span {
    transition: 
        transform var(--duration-normal) var(--ease-out-quart),
        opacity var(--duration-fast);
}

nav.active a {
    animation: mobileNavIn var(--duration-slow) var(--ease-out-expo) both;
}

nav.active a:nth-child(1) { animation-delay: 100ms; }
nav.active a:nth-child(2) { animation-delay: 150ms; }
nav.active a:nth-child(3) { animation-delay: 200ms; }
nav.active a:nth-child(4) { animation-delay: 250ms; }
nav.active a:nth-child(5) { animation-delay: 300ms; }
nav.active a:nth-child(6) { animation-delay: 350ms; }
nav.active a:nth-child(7) { animation-delay: 400ms; }

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

/* ----------------------------------------
   Calendar Day Button Effects
   ---------------------------------------- */
.day-btn {
    transition: 
        background-color var(--duration-fast) var(--ease-out-quart),
        border-color var(--duration-fast),
        color var(--duration-fast),
        transform var(--duration-fast) var(--ease-out-quart),
        box-shadow var(--duration-fast);
}

.day-btn:hover:not(.active) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.day-btn.active {
    animation: daySelect var(--duration-normal) var(--ease-spring);
}

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

/* ----------------------------------------
   Sidebar Slide Animation (Mobile)
   ---------------------------------------- */
.sidebar {
    transition: transform var(--duration-slow) var(--ease-out-expo);
}

.sidebar.active {
    animation: sidebarIn var(--duration-slow) var(--ease-out-expo);
}

@keyframes sidebarIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Sidebar overlay fade */
.sidebar-overlay {
    transition: opacity var(--duration-normal) var(--ease-out-quart);
}

/* ----------------------------------------
   User Card Interactions
   ---------------------------------------- */
.user-card {
    transition: 
        background-color var(--duration-fast) var(--ease-out-quart),
        transform var(--duration-fast) var(--ease-out-quart),
        box-shadow var(--duration-fast);
}

.user-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ----------------------------------------
   Auth Card Animation
   ---------------------------------------- */
.auth-card {
    animation: authCardIn var(--duration-slower) var(--ease-out-expo);
}

@keyframes authCardIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Social button hover */
.btn-social,
.btn-social-text {
    transition: 
        background-color var(--duration-fast) var(--ease-out-quart),
        transform var(--duration-fast) var(--ease-out-quart),
        box-shadow var(--duration-fast);
}

.btn-social:hover,
.btn-social-text:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ----------------------------------------
   Password Toggle Interaction
   ---------------------------------------- */
.toggle-password {
    transition: 
        color var(--duration-fast),
        transform var(--duration-fast) var(--ease-out-quart);
}

.toggle-password:hover {
    transform: scale(1.1);
}

.toggle-password:active {
    transform: scale(0.95);
}

/* ----------------------------------------
   Scroll to Top Button (if added)
   ---------------------------------------- */
.scroll-to-top {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: 
        opacity var(--duration-normal) var(--ease-out-quart),
        transform var(--duration-normal) var(--ease-out-quart),
        visibility var(--duration-normal);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-4px);
}

