/* ============================================
   Professional Loader with Car Maintenance Theme
   ============================================ */

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Animated Background Particles */
.page-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(245, 158, 11, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(251, 191, 36, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 40% 20%, rgba(245, 158, 11, 0.08) 0%, transparent 40%);
    animation: particleFloat 10s ease-in-out infinite;
}

@keyframes particleFloat {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.1) rotate(180deg);
        opacity: 0.8;
    }
}

/* Logo Container */
.loader-logo {
    margin-bottom: 40px;
    animation: fadeInDown 0.8s ease-out;
}

.loader-logo img {
    height: 80px;
    width: auto;
    filter: brightness(0) invert(1);
    animation: pulse 2s ease-in-out infinite;
}

/* Main Loader Container */
.loader-container {
    position: relative;
    width: 200px;
    height: 200px;
}

/* ============================================
   Oil Can Loader Animation
   ============================================ */
.oil-can-loader {
    position: relative;
    width: 100%;
    height: 100%;
}

.oil-can {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 80px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 8px 8px 4px 4px;
    animation: tiltCan 2s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

.oil-can::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -15px;
    width: 40px;
    height: 25px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 0 8px 8px 0;
    transform-origin: left center;
}

.oil-can::after {
    content: 'OIL';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
    font-family: Arial, sans-serif;
}

/* Oil Drops */
.oil-drop {
    position: absolute;
    bottom: 40px;
    left: 50%;
    width: 12px;
    height: 15px;
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    opacity: 0;
    animation: dropFall 2s ease-in infinite;
}

.oil-drop:nth-child(2) {
    animation-delay: 0.4s;
}

.oil-drop:nth-child(3) {
    animation-delay: 0.8s;
}

.oil-drop:nth-child(4) {
    animation-delay: 1.2s;
}

.oil-drop:nth-child(5) {
    animation-delay: 1.6s;
}

/* Oil Pool */
.oil-pool {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 15px;
    background: radial-gradient(ellipse at center, rgba(245, 158, 11, 0.8) 0%, rgba(245, 158, 11, 0.4) 70%, transparent 100%);
    border-radius: 50%;
    animation: poolExpand 2s ease-in-out infinite;
}

/* ============================================
   Steering Wheel Loader
   ============================================ */
.steering-wheel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border: 8px solid #f59e0b;
    border-radius: 50%;
    animation: rotateSteering 2s linear infinite;
    box-shadow:
        0 0 20px rgba(245, 158, 11, 0.4),
        inset 0 0 20px rgba(245, 158, 11, 0.2);
}

.steering-wheel::before,
.steering-wheel::after {
    content: '';
    position: absolute;
    background: #f59e0b;
    border-radius: 4px;
}

.steering-wheel::before {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 8px;
}

.steering-wheel::after {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
    width: 100%;
    height: 8px;
}

.steering-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Engine Piston Loader
   ============================================ */
.engine-loader {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.piston {
    position: relative;
    width: 25px;
    height: 100px;
    background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
    border-radius: 8px 8px 4px 4px;
    animation: pistonMove 1.5s ease-in-out infinite;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.piston::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 20px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 8px 8px 0 0;
}

.piston::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    height: 15px;
    background: #475569;
    border-radius: 50%;
}

.piston:nth-child(1) {
    animation-delay: 0s;
}

.piston:nth-child(2) {
    animation-delay: 0.3s;
}

.piston:nth-child(3) {
    animation-delay: 0.6s;
}

.piston:nth-child(4) {
    animation-delay: 0.9s;
}

.engine-base {
    position: absolute;
    bottom: 20px;
    width: 150px;
    height: 30px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Gear Loader
   ============================================ */
.gear-loader {
    position: relative;
    width: 100%;
    height: 100%;
}

.gear {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border: 8px solid #f59e0b;
    border-radius: 50%;
    animation: rotateGear 3s linear infinite;
}

.gear::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 24px;
    background: #f59e0b;
    border-radius: 4px;
}

.gear-tooth {
    position: absolute;
    width: 16px;
    height: 24px;
    background: #f59e0b;
    border-radius: 4px;
}

.gear-tooth:nth-child(1) {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.gear-tooth:nth-child(2) {
    right: -12px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

.gear-tooth:nth-child(3) {
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.gear-tooth:nth-child(4) {
    left: -12px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

.gear-small {
    position: absolute;
    top: 20%;
    right: 10%;
    width: 50px;
    height: 50px;
    border: 6px solid #fbbf24;
    border-radius: 50%;
    animation: rotateGear 2s linear infinite reverse;
}

/* ============================================
   Loading Text
   ============================================ */
.loader-text {
    margin-top: 30px;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    animation: fadeInUp 0.8s ease-out 0.3s both;
    font-family: 'Cairo', 'Roboto', sans-serif;
}

.loader-text .dots {
    display: inline-block;
}

.loader-text .dots span {
    animation: dotBounce 1.4s infinite;
    display: inline-block;
}

.loader-text .dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-text .dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Progress Bar */
.loader-progress {
    margin-top: 20px;
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
    border-radius: 2px;
    animation: progressLoad 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

/* ============================================
   Animations
   ============================================ */
@keyframes tiltCan {
    0%, 20% {
        transform: translateX(-50%) rotate(0deg);
    }
    30%, 70% {
        transform: translateX(-50%) rotate(45deg);
    }
    80%, 100% {
        transform: translateX(-50%) rotate(0deg);
    }
}

@keyframes dropFall {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100px) scale(0.5);
    }
}

@keyframes poolExpand {
    0%, 20% {
        width: 60px;
        opacity: 0.4;
    }
    40%, 60% {
        width: 100px;
        opacity: 0.8;
    }
    80%, 100% {
        width: 60px;
        opacity: 0.4;
    }
}

@keyframes rotateSteering {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes rotateGear {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

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

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

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
}

@keyframes progressLoad {
    0% {
        width: 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

@keyframes pistonMove {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-30px);
    }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .loader-logo img {
        height: 60px;
    }

    .loader-container {
        width: 150px;
        height: 150px;
    }

    .oil-can {
        width: 50px;
        height: 65px;
    }

    .steering-wheel {
        width: 100px;
        height: 100px;
    }

    .piston {
        width: 20px;
        height: 80px;
    }

    .engine-loader {
        gap: 12px;
    }

    .engine-base {
        width: 120px;
        height: 25px;
    }

    .gear {
        width: 65px;
        height: 65px;
        border-width: 6px;
    }

    .gear-small {
        width: 40px;
        height: 40px;
        border-width: 5px;
    }

    .loader-text {
        font-size: 1rem;
    }

    .loader-progress {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .loader-logo img {
        height: 50px;
    }

    .loader-container {
        width: 120px;
        height: 120px;
    }

    .oil-can {
        width: 40px;
        height: 55px;
    }

    .steering-wheel {
        width: 80px;
        height: 80px;
        border-width: 6px;
    }

    .piston {
        width: 16px;
        height: 65px;
    }

    .engine-loader {
        gap: 10px;
    }

    .engine-base {
        width: 100px;
        height: 20px;
    }

    .gear {
        width: 55px;
        height: 55px;
        border-width: 5px;
    }

    .gear-small {
        width: 35px;
        height: 35px;
        border-width: 4px;
    }

    .loader-text {
        font-size: 0.9rem;
    }

    .loader-progress {
        width: 120px;
        height: 3px;
    }
}

/* RTL Support */
[dir="rtl"] .oil-can::before {
    right: auto;
    left: -15px;
    transform-origin: right center;
}
