/* Custom styles for WebP Converter - Modern Design */

/* Logo styling */
.webp-logo {
    height: 45px;
    width: auto;
}

/* Desktop logo sizing */
@media (min-width: 768px) {
    .webp-logo {
        height: 55px;
    }
}

@media (min-width: 1024px) {
    .webp-logo {
        height: 60px;
    }
}

/* Global styles */
* {
    scroll-behavior: smooth;
    box-sizing: border-box;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    width: 100%;
    min-width: 320px;
}

/* Form controls styling with dark gradient */
.form-radio {
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 3px solid #374151;
    border-radius: 50%;
    background: #1f2937;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.form-radio:hover {
    border-color: #22d3ee;
    transform: scale(1.05);
}

.form-radio:checked {
    border-color: #06b6d4;
    background: linear-gradient(135deg, #06b6d4, #14b8a6);
    transform: scale(1.1);
}

.form-radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0.5rem;
    height: 0.5rem;
    background: white;
    border-radius: 50%;
}

/* Enhanced drag and drop styling */
#dropZone {
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

#dropZone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(147, 51, 234, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

#dropZone.drag-over {
    border-color: #9333ea;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(59, 130, 246, 0.1));
    transform: scale(1.02);
    box-shadow: 0 20px 40px rgba(147, 51, 234, 0.2);
}

#dropZone.drag-over::before {
    transform: translateX(100%);
}

/* Enhanced image thumbnails */
.image-thumbnail {
    transition: all 0.4s ease;
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
}

.image-thumbnail:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border-color: #9333ea;
}

.image-thumbnail img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    transition: all 0.3s ease;
}

.image-thumbnail:hover img {
    transform: scale(1.1);
}

.image-thumbnail .remove-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.image-thumbnail:hover .remove-btn {
    opacity: 1;
    transform: scale(1.1);
}

.image-thumbnail .remove-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: scale(1.2);
}

/* Enhanced position buttons - Dark Theme */
.position-btn {
    transition: all 0.3s ease;
    border-radius: 0.75rem;
    background: #1f2937;
    border: 2px solid #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.position-btn:hover {
    border-color: #22d3ee;
    background: #111827;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(34, 211, 238, 0.2);
}

.position-btn.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(20, 184, 166, 0.2));
    border-color: #06b6d4 !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.4) !important;
}

/* Position button inner elements */
.position-btn .bg-gray-200 {
    background: #374151 !important;
}

.position-btn .bg-blue-600 {
    background: #22d3ee !important;
}

.position-btn:hover .bg-gray-200 {
    background: #4b5563 !important;
}

.position-btn.active .bg-gray-200 {
    background: #4b5563 !important;
}

.position-btn.active .bg-blue-600 {
    background: #06b6d4 !important;
}

/* Enhanced range sliders - Dark Theme */
input[type="range"] {
    height: 0.75rem;
    border-radius: 0.375rem;
    background: linear-gradient(90deg, #374151, #4b5563);
    outline: none;
    appearance: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

input[type="range"]:hover {
    background: linear-gradient(90deg, #4b5563, #6b7280);
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4, #14b8a6);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.6);
}

input[type="range"]::-moz-range-thumb {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4, #14b8a6);
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
    transition: all 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.6);
}

/* Enhanced preview and processed image containers */
.preview-image, .processed-image {
    position: relative;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: all 0.4s ease;
    background: white;
    border: 2px solid transparent;
}

.preview-image:hover, .processed-image:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    border-color: #9333ea;
}

.preview-image img, .processed-image img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: all 0.3s ease;
}

.preview-image:hover img, .processed-image:hover img {
    transform: scale(1.05);
}

.preview-image .image-info, .processed-image .image-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    color: white;
    padding: 2rem 1rem 1rem;
    font-size: 0.875rem;
    backdrop-filter: blur(10px);
}

.processed-image .image-info button {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.processed-image .image-info button:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

/* Loading states with enhanced animation */
.loading-spinner {
    border-top-color: transparent;
    animation: spin 1s linear infinite, pulse 2s ease-in-out infinite;
    border-width: 3px;
    border-color: #9333ea;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

/* Enhanced language menu - Dark Theme */
/* Desktop dropdown styles - overridden by mobile styles below */

#languageMenu.hidden {
    animation: slideOut 0.3s ease;
}

.lang-option {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0.75rem;
    margin: 0.125rem;
    position: relative;
    overflow: hidden;
}

.lang-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.1), transparent);
    transition: left 0.6s ease;
}

.lang-option:hover::before {
    left: 100%;
}

.lang-option:hover {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(20, 184, 166, 0.15));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.2);
}

/* Language button enhanced dark styles */
#languageButton {
    position: relative;
    overflow: hidden;
}

#languageButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

#languageButton:hover::before {
    left: 100%;
}

/* Language button enhanced styles */
#languageButton {
    position: relative;
    overflow: hidden;
}

#languageButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.6s ease;
}

#languageButton:hover::before {
    left: 100%;
}

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

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

/* RTL support for Arabic with enhanced styling */
html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] .text-left {
    text-align: right;
}

html[dir="rtl"] .text-right {
    text-align: left;
}

html[dir="rtl"] .ml-2 {
    margin-left: 0;
    margin-right: 0.5rem;
}

html[dir="rtl"] .mr-2 {
    margin-left: 0.5rem;
    margin-right: 0;
}

html[dir="rtl"] .lang-option:hover {
    transform: translateX(-4px);
}

/* Responsive enhancements */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
        max-width: 100%;
        width: 100%;
        margin: 0;
    }
    
    main {
        padding: 1rem;
        margin: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .grid-cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
    
    .position-btn {
        padding: 0.75rem 0.5rem;
    }
    
    #dropZone {
        padding: 2rem 1rem;
        margin: 0;
        width: 100%;
        font-size: 0.9rem;
    }
    
    #dropZone .text-8xl {
        font-size: 4rem;
    }
    
    #dropZone h3 {
        font-size: 1.5rem;
    }
    
    #dropZone p {
        font-size: 1rem;
    }

    .preview-image img, .processed-image img {
        height: 160px;
    }

    .image-thumbnail img {
        height: 100px;
    }

    /* Hero section mobile fixes */
    .hero-section {
        padding: 2rem 0;
        margin-bottom: 2rem;
    }
    
    .hero-section .relative {
        padding: 2rem 1rem;
    }
    
    .hero-section h2 {
        font-size: 2rem !important;
        line-height: 1.2;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
        word-break: break-word;
        hyphens: auto;
        overflow-wrap: break-word;
    }
    
    .hero-section p {
        font-size: 1rem !important;
        line-height: 1.5;
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }
    
    .hero-section .flex {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
    
    /* Header mobile fixes */
    header {
        padding: 0.5rem 0;
    }
    
    header .container {
        padding: 0.75rem 1rem;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    
    header img {
        height: 55px !important;
        width: auto;
        flex-shrink: 0;
    }
    
    header .flex {
        width: 100%;
        gap: 0.5rem;
    }
    
    /* Mobile dropdown positioning - Fixed */
    #languageMenu {
        position: fixed !important;
        top: 80px !important;
        right: 1rem !important;
        left: auto !important;
        width: 220px !important;
        max-width: calc(100vw - 2rem) !important;
        max-height: 70vh !important;
        background: rgba(17, 24, 39, 0.98) !important;
        border: 2px solid #22d3ee !important;
        border-radius: 0.75rem !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.8) !important;
        z-index: 9999999 !important;
        backdrop-filter: blur(20px) !important;
        overflow-y: auto !important;
    }
    
    .lang-option {
        padding: 0.75rem 1rem;
        cursor: pointer !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        touch-action: manipulation !important;
    }
    
    .lang-option:hover, .lang-option:active, .lang-option:focus {
        outline: none !important;
    }
    
    .lang-option span {
        font-size: 0.875rem;
    }
    
    .lang-option .text-xl {
        font-size: 1rem;
    }
    
    /* Modern cyan dropdown styling - Mobile optimized */
    #languageButton {
        background: transparent !important;
        border: 2px solid #22d3ee !important;
        border-radius: 0.5rem !important;
        padding: 0.5rem 1rem !important;
        min-width: auto !important;
        box-shadow: none !important;
        cursor: pointer !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(34, 211, 238, 0.3) !important;
    }
    
    #languageButton:hover, #languageButton:active, #languageButton:focus, #languageButton:active:focus {
        background: rgba(34, 211, 238, 0.1) !important;
        border-color: #22d3ee !important;
        transform: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    /* Ensure proper stacking context */
    header {
        z-index: 1000;
        position: relative;
    }
    
    header .relative {
        z-index: 1001;
    }
    
    
    /* Section spacing */
    section {
        margin-bottom: 1.5rem;
        padding: 1.5rem 1rem;
    }
    
    /* Cards and controls */
    .bg-white\/80 {
        padding: 1.5rem 1rem;
    }
    
    /* FAQ section mobile */
    .faq-question {
        padding: 1rem;
    }
    
    .faq-question h3 {
        font-size: 0.95rem;
        line-height: 1.4;
        padding-right: 1.5rem;
    }
    
    .faq-answer {
        padding: 0 1rem 1rem;
    }
    
    .faq-answer p {
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    /* Grid improvements */
    .grid {
        gap: 1rem;
    }
    
    /* Button improvements */
    button {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
    
    /* Form improvements */
    input, textarea {
        font-size: 1rem;
        padding: 0.75rem;
    }
}

@media (max-width: 640px) {
    #dropZone {
        padding: 2rem 1rem;
        margin: 0 0.5rem;
        width: calc(100% - 1rem);
    }

    .preview-image img, .processed-image img {
        height: 160px;
    }

    /* Extra small screens - ensure text fits */
    .hero-section h2 {
        font-size: 1.875rem !important; /* 30px */
        line-height: 1.2;
        word-spacing: -0.1em;
        letter-spacing: -0.02em;
    }

    .hero-section p {
        font-size: 1.125rem !important; /* 18px */
        line-height: 1.4;
    }
    
    /* Header very small screens */
    header img {
        height: 50px !important;
        width: auto;
        flex-shrink: 0;
    }
    
    header .container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.25rem;
        padding: 0.75rem 0.25rem;
    }
    
    header .flex.items-center {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }
    
    #languageButton {
        padding: 0.5rem 0.75rem;
        min-width: auto;
    }
    
    #languageButton span {
        font-size: 0.875rem;
    }
    
    /* Sections mobile fix */
    section {
        margin: 0;
        padding-left: 1rem;
        padding-right: 1rem;
        width: 100%;
        max-width: 100%;
    }
    
    .container {
        margin: 0;
        padding: 1rem;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    /* Very small screens */
    .hero-section h2 {
        font-size: 1.5rem !important; /* 24px */
        line-height: 1.3;
        padding: 0 0.5rem;
    }
    
    .hero-section p {
        font-size: 1rem !important; /* 16px */
        padding: 0 0.5rem;
    }

    .flex.justify-center.space-x-8 {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .flex.justify-center.space-x-8 > div {
        margin: 0;
    }
    
    /* Ultra small header */
    header img {
        height: 45px !important;
        width: auto;
    }
    
    header .container {
        padding: 0.5rem 0.25rem;
        min-height: auto;
    }
    
    header {
        min-height: auto;
    }
    
    #languageButton {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Ultra small screen fixes */
    body {
        font-size: 14px;
    }
    
    .container, main {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        margin: 0 !important;
    }
    
    section {
        padding: 1rem 0.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Hero ultra small */
    .hero-section h2 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.75rem !important;
    }
    
    .hero-section p {
        font-size: 0.95rem !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-section .relative {
        padding: 1.5rem 0.5rem !important;
    }
    
    /* FAQ accordion ultra small */
    .faq-question h3 {
        font-size: 0.875rem;
        line-height: 1.3;
    }
    
    .faq-answer p {
        font-size: 0.8rem;
        line-height: 1.4;
    }
}

/* Enhanced success animations */
.success-animation {
    animation: successPulse 0.8s ease, glow 2s ease-in-out infinite;
}

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(34, 197, 94, 0.6);
    }
}

/* Custom scrollbar for language menu */
#languageMenu::-webkit-scrollbar {
    width: 6px;
}

#languageMenu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#languageMenu::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #9333ea, #3b82f6);
    border-radius: 3px;
}

#languageMenu::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c3aed, #2563eb);
}

/* Focus styles for accessibility with gradient */
button:focus, input:focus, [tabindex]:focus {
    outline: 3px solid rgba(147, 51, 234, 0.6);
    outline-offset: 2px;
}

/* Loading overlay enhancement */
#loadingOverlay {
    backdrop-filter: blur(10px);
}

#loadingOverlay > div {
    background: white/90;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Input field enhancements - Dark Theme */
input[type="text"], input[type="file"], textarea {
    transition: all 0.3s ease;
    border-radius: 0.75rem;
    border: 2px solid #374151;
    background: #1f2937;
    color: #f3f4f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

input[type="text"]:focus, input[type="file"]:focus, textarea:focus {
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2), 0 4px 12px rgba(0, 0, 0, 0.3);
    background: #111827;
}

input[type="text"]::placeholder {
    color: #9ca3af;
}

/* File input styling */
input[type="file"] {
    color: #f3f4f6;
}

input[type="file"]::-webkit-file-upload-button {
    background: linear-gradient(135deg, #06b6d4, #14b8a6);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="file"]::-webkit-file-upload-button:hover {
    background: linear-gradient(135deg, #0891b2, #0f766e);
    transform: scale(1.02);
}

/* Enhanced hero section animations */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

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

/* Prevent horizontal scroll on all elements */
.no-scroll {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Container width fixes */
.w-full {
    width: 100% !important;
    max-width: 100% !important;
}

/* Text wrapping for all text elements */
p, span, h1, h2, h3, h4, h5, h6, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* Button hover effects */
button:not(:disabled):hover {
    animation: buttonPulse 0.3s ease;
}

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

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
    }
    
    * {
        box-shadow: none !important;
    }
}