/**
 * Custom WooCommerce My Account Styles
 * Supplements Tailwind CSS with additional customizations
 */

/* ==========================================================================
   Base Styles & Overrides
   ========================================================================== */

/* Hide default WooCommerce My Account navigation */
.woocommerce-MyAccount-navigation {
    display: none !important;
}

/* Hide default WooCommerce content wrapper when custom account is active */
.woocommerce-account-custom .woocommerce-MyAccount-content {
    padding: 0;
}

/* Root container */
#custom-woo-account-root {
    width: 100%;
    /* min-height removed - App.js already sets min-h-screen to prevent duplicate min-height */
}

/* Loading spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    font-size: 18px;
    color: #6b7280;
}

.loading-spinner::before {
    content: "";
    width: 40px;
    height: 40px;
    margin-right: 12px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Smooth Transitions & Animations
   ========================================================================== */

/* Fade in animation for content */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#custom-woo-account-root > div {
    animation: fadeIn 0.3s ease-out;
}

/* Button hover effects */
button {
    transition: all 0.2s ease-in-out;
}

button:active {
    transform: scale(0.98);
}

/* Card hover effects */
.hover\:bg-gray-50:hover,
.hover\:bg-red-50:hover {
    transition: background-color 0.2s ease;
}

/* ==========================================================================
   Custom Scrollbar
   ========================================================================== */

#custom-woo-account-root ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#custom-woo-account-root ::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

#custom-woo-account-root ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#custom-woo-account-root ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================================================
   Status Badge Animations
   ========================================================================== */

.status-badge {
    position: relative;
    overflow: hidden;
}

.status-badge::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;
}

.status-badge:hover::before {
    left: 100%;
}

/* ==========================================================================
   Input Focus States
   ========================================================================== */

input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ==========================================================================
   Gradient Card Enhancements
   ========================================================================== */

.gradient-card {
    position: relative;
    overflow: hidden;
}

.gradient-card::after {
    content: "";
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gradient-card:hover::after {
    opacity: 1;
}

/* ==========================================================================
   Sidebar Sticky Positioning (Desktop >= 1280px)
   ========================================================================== */

@media (min-width: 1280px) {
    .sticky {
        position: sticky;
        top: 2rem;
    }
}

/* ==========================================================================
   Sidebar Responsive Behavior
   ========================================================================== */

/* Sidebar wrapper - responsive width */
.sidebar-wrapper {
    display: block;
    flex-shrink: 0;
}

/* Desktop sidebar (>= 1280px) */
@media (min-width: 1280px) {
    .sidebar-wrapper {
        width: 256px;
    }
}

/* Mobile/Tablet sidebar (< 1280px) */
@media (max-width: 1279px) {
    .sidebar-wrapper {
        width: 100%;
        max-width: 280px;
    }

    /* Make sidebar not sticky on mobile */
    .sidebar-wrapper .sticky {
        position: relative !important;
    }
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */

/* Safe area padding for notched devices */
.safe-area-pt {
    padding-top: max(1rem, env(safe-area-inset-top));
}

.safe-area-pb {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Mobile Floating Button */
@media (max-width: 1023px) {
    /* Floating button slide up animation */
    .animate-slide-up {
        animation: slideUpFromBottom 0.4s ease-out;
    }

    /* Mobile drawer animation */
    .slide-in-left {
        animation: slideInFromLeft 0.3s ease-out;
    }

    /* Overlay fade-in */
    .bg-black\/50 {
        animation: fadeIn 0.2s ease-out;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 1023px) {
    body {
        overflow-x: hidden;
    }

    #custom-woo-account-root {
        overflow-x: hidden;
    }
}

/* Mobile styles for screens < 1024px */
@media (max-width: 1023px) {
    /* Stack cards vertically on mobile */
    .grid.grid-cols-1.md\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

    /* Reduce padding on mobile */
    #custom-woo-account-root .p-6 {
        padding: 1rem !important;
    }

    #custom-woo-account-root .p-8 {
        padding: 1.25rem !important;
    }

    /* Make sidebar not sticky on mobile */
    .sticky {
        position: relative !important;
    }

    /* Adjust font sizes for better mobile readability */
    .text-2xl {
        font-size: 1.5rem !important;
    }

    .text-3xl {
        font-size: 1.875rem !important;
    }

    .text-4xl {
        font-size: 2.25rem !important;
    }

    /* Touch-friendly button sizes - minimum 44px height */
    button {
        min-height: 44px;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }

    /* Larger tap targets for mobile navigation */
    nav button {
        min-height: 48px;
    }

    /* Better spacing for mobile forms */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        min-height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Reduce gap between grid items on mobile */
    .gap-6 {
        gap: 1rem !important;
    }

    /* Better mobile padding for cards */
    .rounded-xl {
        border-radius: 0.75rem;
    }

    /* Mobile-specific order details layout */
    .xl\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

    /* Stack order summary below items on mobile */
    .xl\:col-span-2 {
        order: 1;
    }

    .xl\:col-span-1 {
        order: 2;
    }
}

/* Extra small phones < 375px */
@media (max-width: 374px) {
    /* Even smaller text for very small screens */
    .text-xl {
        font-size: 1.125rem !important;
    }

    .text-2xl {
        font-size: 1.25rem !important;
    }

    /* Tighter padding */
    #custom-woo-account-root .p-4 {
        padding: 0.75rem !important;
    }

    /* Smaller badge sizes */
    .text-xs {
        font-size: 0.675rem !important;
    }
}

/* Tablet styles 768px - 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
    /* 2-column grid for theme selector on tablet */
    .theme-selector-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Better use of tablet space */
    .max-w-7xl {
        max-width: 100%;
    }
}

/* ==========================================================================
   Toggle Switch Enhancements
   ========================================================================== */

.toggle-switch {
    cursor: pointer;
    user-select: none;
}

.toggle-switch span {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Order Item Hover Effect
   ========================================================================== */

.order-item {
    position: relative;
    transition: all 0.2s ease;
}

.order-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Badge Pulse Animation
   ========================================================================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.badge-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    /* Hide sidebar on print */
    .lg\:w-64 {
        display: none;
    }

    /* Make content full width */
    .flex-1 {
        width: 100%;
    }
    
    /* Remove background gradients */
    .bg-gradient-to-br,
    .bg-gradient-to-r {
        background: white !important;
        color: black !important;
    }
    
    /* Hide interactive elements */
    button {
        display: none;
    }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    button,
    input,
    select,
    textarea {
        border: 2px solid currentColor;
    }
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode */
    /*
    #custom-woo-account-root {
        color-scheme: dark;
    }
    
    .bg-white {
        background-color: #1f2937 !important;
    }
    
    .text-gray-900 {
        color: #f9fafb !important;
    }
    
    .text-gray-600 {
        color: #d1d5db !important;
    }
    
    .border-gray-200 {
        border-color: #374151 !important;
    }
    
    .bg-gray-50 {
        background-color: #111827 !important;
    }
    */
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Glass morphism effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* No select */
.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ==========================================================================
   WooCommerce Compatibility
   ========================================================================== */

/* Ensure compatibility with WooCommerce notices */
.woocommerce-error,
.woocommerce-info,
.woocommerce-message {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.5rem;
}

/* Fix for WooCommerce form fields */
.woocommerce-account .woocommerce form .form-row {
    padding: 0;
    margin: 0;
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* GPU acceleration for animations */
.animate-gpu {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Prevent layout shift */
img,
svg {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   Custom Animations
   ========================================================================== */

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideUpFromBottom {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.slide-in-left {
    animation: slideInFromLeft 0.3s ease-out;
}

.slide-in-right {
    animation: slideInFromRight 0.3s ease-out;
}

/* ==========================================================================
   Profile Picture Rounded Corners
   ========================================================================== */

/* Force rounded corners for profile pictures - override any circular styles */
#custom-woo-account-root img[alt*="Profile"],
#custom-woo-account-root img[alt*="profile"] {
    border-radius: 1rem !important; /* rounded-xl = 0.75rem, rounded-2xl = 1rem */
}

/* Ensure Sidebar avatar uses rounded corners */
.sticky img {
    border-radius: 0.75rem !important; /* rounded-xl */
}

/* Ensure Settings page profile picture preview uses larger rounded corners */
.space-y-4 img[alt*="Profile"],
.space-y-4 img[alt*="profile"] {
    border-radius: 1rem !important; /* rounded-2xl */
}

/* Also apply to avatar placeholder divs */
.sticky > div > div:first-child > div {
    border-radius: 0.75rem !important;
}

.space-y-4 > div > div > div {
    border-radius: 1rem !important;
}