/**
 * Baba Fua - Custom Styles
 * Additional styles for animations and custom components
 */

/* Global Box Sizing and Overflow Prevention */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}

/* Prevent horizontal scroll on all screen sizes */
@media (max-width: 767px) {
    body {
        overflow-x: hidden !important;
    }
    
    .max-w-7xl,
    .max-w-full {
        max-width: 100% !important;
    }
}

/* Ensure main content containers don't overflow */
main,
#main-content {
    overflow-x: hidden;
    max-width: 100%;
}

/* Ensure header links are clickable */
header a {
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
}

header nav a {
    display: inline-block;
    text-decoration: none;
}

/* Logo Animation Styles */
header a[href*="login"] .animate-bounce-slow {
    animation: bounce-slow 3s ease-in-out infinite;
}

header a[href*="login"] .animate-float {
    animation: float 2s ease-in-out infinite;
}

/* Logo Image Styles */
header a[href*="login"] img {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: filter 0.3s ease;
}

header a[href*="login"]:hover img {
    filter: drop-shadow(0 4px 8px rgba(255, 255, 255, 0.3)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Logo Hover Effects */
header a[href*="login"]:hover {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* Shimmer effect for logo text */
header a[href*="login"] span[class*="bg-gradient-to-r"] {
    background-size: 200% auto;
    animation: shimmer 3s linear infinite;
}

/* Logo container adjustments */
header a[href*="login"] {
    text-decoration: none;
    display: flex;
    align-items: center;
}

/* Ensure logo image doesn't break layout */
header a[href*="login"] img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Login for Discount Button Animation */
@keyframes pulse-glow-discount {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 0 20px rgba(239, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0), 0 0 30px rgba(239, 68, 68, 0.5);
    }
}

header button[onclick*="openLoginModal"] {
    animation: pulse-glow-discount 2s ease-in-out infinite;
}

/* Responsive adjustments for login button */
@media (max-width: 640px) {
    header button[onclick*="openLoginModal"] {
        min-height: 44px; /* Touch-friendly size */
        font-size: 0.875rem;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    header button[onclick*="openLoginModal"] {
        min-height: 40px;
    }
}

@media (min-width: 1025px) {
    header button[onclick*="openLoginModal"] {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    header button[onclick*="openLoginModal"] {
        animation: none;
    }
    
    header button[onclick*="openLoginModal"] span span {
        animation: none !important;
    }
}

/* Custom animations with prefers-reduced-motion support */
@media (prefers-reduced-motion: no-preference) {
    @keyframes float {
        0%, 100% { 
            transform: translateY(0) translateX(0); 
        }
        50% { 
            transform: translateY(-20px) translateX(10px); 
        }
    }
    
    @keyframes bounce-slow {
        0%, 100% {
            transform: translateY(0) scale(1);
        }
        50% {
            transform: translateY(-8px) scale(1.05);
        }
    }
    
    @keyframes shimmer {
        0% {
            background-position: -200% center;
        }
        100% {
            background-position: 200% center;
        }
    }
    
    @keyframes bubble-rise {
        0% { 
            transform: translateY(100vh) scale(0); 
            opacity: 0; 
        }
        10% { 
            opacity: 0.3; 
        }
        90% { 
            opacity: 0.3; 
        }
        100% { 
            transform: translateY(-100px) scale(1); 
            opacity: 0; 
        }
    }
    
    @keyframes fade-in-up {
        from { 
            opacity: 0; 
            transform: translateY(20px); 
        }
        to { 
            opacity: 1; 
            transform: translateY(0); 
        }
    }
    
    @keyframes pulse-glow {
        0%, 100% {
            box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.7);
        }
        50% {
            box-shadow: 0 0 0 10px rgba(14, 165, 233, 0);
        }
    }
    
    .animate-float {
        animation: float 6s ease-in-out infinite;
    }
    
    .animate-bubble {
        animation: bubble-rise linear infinite;
    }
    
    .animate-fade-in-up {
        animation: fade-in-up 0.6s ease-out;
    }
    
    .animate-pulse-glow {
        animation: pulse-glow 2s ease-in-out infinite;
    }
}

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

/* Water bubble styling */
.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(14, 165, 233, 0.2), rgba(14, 165, 233, 0.05));
    pointer-events: none;
    z-index: 1;
    animation: bubble-rise linear infinite;
}

/* Hero background image styling */
#hero {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#hero img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

/* Gradient background utility */
.gradient-bg {
    background: linear-gradient(135deg, #EBF8FF 0%, #F8FAFC 100%);
}

/* Smooth transitions for interactive elements */
a, button {
    transition: all 0.2s ease-in-out;
}

/* Scrollbar hide utility for horizontal scrolling tabs */
.scrollbar-hide {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

/* Custom scrollbar (optional, for webkit browsers) */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #0EA5E9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0369A1;
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid #0EA5E9;
    outline-offset: 2px;
}

/* Role-based animation classes */
.role-customer .animate-role {
    animation: float 6s ease-in-out infinite;
}

.role-rider .animate-role {
    animation: pulse-glow 2s ease-in-out infinite;
}

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

.role-admin .animate-role {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Mobile menu animations */
@media (max-width: 768px) {
    #mobile-menu {
        transition: transform 0.3s ease-in-out;
    }
    
    #mobile-sidebar {
        transition: transform 0.3s ease-in-out;
    }
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0EA5E9;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .bubble,
    #bubbles-container,
    #footer-bubbles {
        display: none !important;
    }
}

/* Auth Modal Styles */
#auth-modal {
    animation: fadeIn 0.3s ease-out;
    -webkit-overflow-scrolling: touch;
}

#modal-container {
    max-height: 100vh;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Mobile-specific adjustments */
@media (max-width: 640px) {
    #modal-container {
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }
    
    #auth-modal {
        padding: 0;
        align-items: flex-start;
        padding-top: 0;
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Smaller text on mobile */
    #modal-container input,
    #modal-container select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Ensure content wrapper is scrollable */
    #modal-content-wrapper {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 3rem;
        max-height: 100%;
    }
    
    /* Make forms scrollable on mobile */
    #login-form,
    #signup-form {
        width: 100%;
        min-height: min-content;
        display: flex;
        flex-direction: column;
    }
    
    /* Ensure header doesn't take too much space */
    #modal-content-wrapper > div:first-child {
        flex-shrink: 0;
    }
    
    /* Prevent content from being cut off */
    #modal-content-wrapper > form {
        padding-bottom: 1rem;
        flex-shrink: 0;
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
    #modal-container {
        max-height: 90vh;
        height: auto;
    }
    
    #modal-content-wrapper {
        max-height: calc(90vh - 4rem);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* Desktop adjustments */
@media (min-width: 1025px) {
    #modal-container {
        max-height: 90vh;
        height: auto;
    }
    
    #modal-content-wrapper {
        max-height: calc(90vh - 4rem);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

#modal-container::-webkit-scrollbar {
    width: 6px;
}

#modal-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#modal-container::-webkit-scrollbar-thumb {
    background: #0EA5E9;
    border-radius: 10px;
}

#modal-container::-webkit-scrollbar-thumb:hover {
    background: #0369A1;
}

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

/* File input styling */
#signup-image {
    position: relative;
}

#signup-image::file-selector-button {
    display: none;
}

#signup-image + div {
    pointer-events: none;
}

/* Password toggle button hover */
[id^="toggle-"]:hover {
    transform: scale(1.1);
    transition: transform 0.2s;
}

/* Form input focus animations */
input:focus,
select:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

/* Modal backdrop blur */
#auth-modal {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Enhanced modal animations */
#modal-container {
    animation: modalSlideUp 0.4s ease-out;
}

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

/* Laundry-themed decorative elements */
#auth-modal .animate-float {
    animation: float 8s ease-in-out infinite;
}

/* Enhanced input hover effects */
input:hover,
select:hover {
    border-color: #0EA5E9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Button shine effect */
.group:hover .absolute.inset-0 {
    animation: shine 1.5s ease-in-out infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) skewX(-12deg);
    }
    100% {
        transform: translateX(200%) skewX(-12deg);
    }
}

/* Enhanced file upload area */
label[for="signup-image"]:hover {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.05), rgba(251, 146, 60, 0.05));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

/* Message box styling */
#login-message,
#signup-message {
    animation: slideDown 0.3s ease-out;
}

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

/* Responsive header adjustments */
@media (max-width: 640px) {
    /* Ensure header doesn't overflow on small screens */
    header {
        min-height: auto;
    }
    
    /* Profile dropdown positioning on mobile */
    #profile-dropdown-menu {
        right: 0.5rem;
        left: auto;
        max-width: calc(100vw - 1rem);
    }
    
    /* Ensure profile button is touch-friendly */
    #profile-dropdown-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Mobile nav menu adjustments */
    #mobile-nav-menu {
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
    #profile-dropdown-menu {
        right: 0;
    }
}

/* Ensure header content doesn't wrap awkwardly */
@media (max-width: 768px) {
    header .flex-wrap {
        flex-wrap: wrap;
    }
    
    /* Prevent text overflow in header */
    header h1,
    header span {
        word-break: break-word;
        overflow-wrap: break-word;
    }
}

/* Profile dropdown responsive text */
@media (max-width: 480px) {
    #profile-dropdown-menu {
        width: calc(100vw - 1rem);
        max-width: 280px;
        right: 0.5rem;
    }
    
    /* Ensure profile button is always visible and touch-friendly */
    #profile-dropdown-toggle {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Extra small screens - show only profile photo */
@media (max-width: 360px) {
    #profile-dropdown-toggle {
        padding: 0.5rem;
    }
    
    #profile-dropdown-menu {
        width: calc(100vw - 0.5rem);
        right: 0.25rem;
    }
}

/* Ensure profile dropdown doesn't overflow on any screen */
#profile-dropdown-menu {
    max-width: calc(100vw - 1rem);
}

/* Profile button hover and active states */
#profile-dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#profile-dropdown-toggle:active {
    transform: scale(0.95);
}

/* Ensure profile section is always visible */
#profile-dropdown-container {
    display: block !important;
    visibility: visible !important;
}

#profile-dropdown-toggle {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Profile Photo and Avatar Logic */
.profile-photo {
    display: block !important;
}

.profile-photo.hidden {
    display: none !important;
}

.profile-avatar-fallback {
    display: flex !important;
}

.profile-avatar-fallback.hidden {
    display: none !important;
}

/* Dropdown profile photo logic */
.dropdown-profile-photo {
    display: block !important;
}

.dropdown-profile-photo.hidden {
    display: none !important;
}

.dropdown-avatar-fallback {
    display: flex !important;
}

.dropdown-avatar-fallback.hidden {
    display: none !important;
}

/* Ensure at least one avatar is always visible */
.profile-avatar-fallback:not(.hidden),
.profile-photo:not(.hidden) {
    visibility: visible !important;
}

/* Make sure username is visible on all screens */
#profile-dropdown-toggle > div.flex.flex-col {
    display: flex !important;
    visibility: visible !important;
}

/* Manager Dashboard Responsive Enhancements */
@media (max-width: 640px) {
    /* Ensure stats cards stack properly on mobile */
    .grid.grid-cols-1.sm\:grid-cols-2 {
        gap: 0.75rem;
    }
    
    /* Manager welcome section mobile adjustments */
    .manager-dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Ensure badges don't wrap awkwardly */
    .manager-badges {
        flex-wrap: wrap;
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Tablet adjustments for manager dashboard */
@media (min-width: 641px) and (max-width: 1024px) {
    /* Optimize card spacing on tablets */
    .grid.grid-cols-1.sm\:grid-cols-2 {
        gap: 1rem;
    }
}

/* Header styles are now in header.css */
/* This ensures header stays fixed */
body {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; /* Account for fixed header */
}

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

/* Header component styles moved to header.css for better organization */

/* Fade in animation for page content */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Employee card animations */
@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.employee-card {
    animation: slide-up 0.3s ease-out;
}

/* Pulse animation for stats cards */
@keyframes pulse-glow-stats {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
    }
}

.stats-card:hover {
    animation: pulse-glow-stats 2s infinite;
}

/* Better typography and spacing */
main h1, main h2, main h3 {
    line-height: 1.2;
    letter-spacing: -0.02em;
}

main p {
    line-height: 1.6;
}

/* Improved card hover effects */
.bg-white.rounded-xl {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-white.rounded-xl:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Loading state for images */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Profile dropdown styles moved to header.css */

/* Ensure main content doesn't cover dropdown and is below header */
main {
    z-index: 0 !important;
    position: relative;
    margin-top: 0 !important;
    padding-top: 64px !important;
    transition: padding-top 0.2s ease;
}

@media (min-width: 640px) {
    main {
        padding-top: 68px !important;
    }
}

@media (min-width: 768px) {
    main {
        padding-top: 76px !important;
    }
}

@media (min-width: 1024px) {
    main {
        padding-top: 80px !important;
    }
}

@media (min-width: 1280px) {
    main {
        padding-top: 84px !important;
    }
}

/* Better focus styles for accessibility */
button:focus-visible,
a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Skip to main content link for accessibility */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    z-index: 10000;
    text-decoration: none;
}

.skip-to-main:focus {
    top: 0;
}

/* Ensure sidebar doesn't cover dropdown */
aside#sidebar {
    z-index: 100 !important;
}

/* Mobile sidebar z-index */
#mobile-sidebar {
    z-index: 200 !important;
}

/* Mobile menu overlay z-index */
#mobile-menu-overlay {
    z-index: 150 !important;
}

/* Ensure dropdown appears above everything */
#profile-dropdown-menu.show {
    z-index: 99999 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Prevent header from scrolling */
body {
    overflow-x: hidden;
}

/* Ensure header stays at top on scroll */
html {
    scroll-behavior: smooth;
}

/* Prevent horizontal scrolling on manager dashboard */
.manager-dashboard-content {
    max-width: 100%;
    overflow-x: hidden;
}

/* Rider Dashboard Responsive Enhancements */
@media (max-width: 640px) {
    /* Rider stats cards mobile optimization */
    .rider-dashboard-stats {
        gap: 0.75rem;
    }
    
    /* Rider welcome section mobile adjustments */
    .rider-dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Ensure rider badges don't wrap awkwardly */
    .rider-badges {
        flex-wrap: wrap;
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Tablet adjustments for rider dashboard */
@media (min-width: 641px) and (max-width: 1024px) {
    /* Optimize rider card spacing on tablets */
    .rider-dashboard-stats {
        gap: 1rem;
    }
}

/* Rider-specific responsive text */
@media (max-width: 480px) {
    /* Ensure rider cards are readable on very small screens */
    .rider-stats-card {
        min-height: 100px;
    }
    
    /* Rider card text sizing */
    .rider-stats-card p {
        font-size: 0.75rem;
    }
    
    .rider-stats-card .text-2xl {
        font-size: 1.5rem;
    }
}

