/**
 * Enhanced RTL Styles for OSM Location Picker - Modern Fullscreen Map Design
 * These styles specifically target RTL languages like Persian and Arabic
 * Fix for tracking page rendering issues
 *
 * @package OSM_Location_Picker
 */

/* RTL Base Styles */
.rtl .osm-container {
    direction: rtl;
    text-align: right;
    position: relative;
}

/* Typography for Persian */
.rtl.fa-IR .osm-container,
.rtl.fa-IR .osm-container h2,
.rtl.fa-IR .osm-container h3,
.rtl.fa-IR .osm-container input,
.rtl.fa-IR .osm-container button,
.rtl.fa-IR .osm-container p,
.rtl.fa-IR .osm-container a {
    font-family: 'IRANSans', 'Vazir', 'Tahoma', sans-serif !important;
}

/* Better RTL Header Styling */
.rtl .osm-container h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 0;
    color: #333;
    padding: 12px 15px;
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px 8px 0 0;
}

/* Full-screen Map Container */
.rtl #osm-checkout-map,
.rtl #osm-order-map,
.rtl #osm-tracker-map,
.rtl .osm-map-container {
    width: 100%;
    height: 450px !important; /* Taller map */
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #eaeaea;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Improved RTL Search Box - Floating on top of the map */
.rtl .osm-search-box {
    position: absolute;
    top: 60px;
    right: 15px;
    left: 15px;
    z-index: 999;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 5px;
    margin-bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rtl .osm-search-box input[type="text"] {
    flex: 1;
    text-align: right;
    padding: 8px 15px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: none;
}

.rtl .osm-search-box input[type="text"]:focus {
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.25);
    background: #fff;
}

/* Modern Transparent Buttons */
.rtl .osm-container .button {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.rtl .osm-container .button:hover {
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Primary button - e.g. search */
.rtl .osm-search-box .button:not(.secondary) {
    background: rgba(52, 152, 219, 0.9);
    color: white;
    border-color: rgba(41, 128, 185, 0.5);
}

.rtl .osm-search-box .button:not(.secondary):hover {
    background: rgba(41, 128, 185, 0.95);
}

/* Secondary button - e.g. use my location */
.rtl .osm-search-box .button.secondary {
    background: rgba(242, 242, 242, 0.9);
    color: #333;
    border-color: rgba(0, 0, 0, 0.1);
}

.rtl .osm-search-box .button.secondary:hover {
    background: rgba(230, 230, 230, 0.95);
}

/* Map Controls Positioning - make them more visible */
.rtl .leaflet-top.leaflet-right {
    left: 15px !important;
    right: auto !important;
    top: 130px !important;
}

.rtl .leaflet-top.leaflet-left {
    right: 15px !important;
    left: auto !important;
    top: 130px !important;
}

.rtl .leaflet-control-zoom a {
    font-size: 18px;
    width: 36px;
    height: 36px;
    line-height: 36px;
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #333 !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1) !important;
}

.rtl .leaflet-control-zoom a:hover {
    background: #fff !important;
    color: #000 !important;
}

/* Address Display Styling - Below the map */
.rtl #osm-address-display {
    position: absolute;
    bottom: 15px;
    right: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 8px;
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    backdrop-filter: blur(5px);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
    z-index: 500;
    max-width: 70%;
}

.rtl .osm-location-selected {
    display: inline-block;
    margin-right: 8px;
    padding: 3px 8px;
    background: rgba(46, 204, 113, 0.2);
    color: #27ae60;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

/* Hidden inputs */
.rtl #osm_location_lat,
.rtl #osm_location_lng {
    display: none;
}

/* Order Complete and Order Details Page */
.rtl .osm-metabox-container {
    border: 1px solid #eaeaea;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
    position: relative;
}

/* QR Code Section */
.rtl #osm-qr-container {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 15px 0;
}

.rtl #osm-qr-code {
    display: inline-block;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Mobile Responsive for RTL */
@media screen and (max-width: 767px) {
    .rtl .osm-search-box {
        flex-direction: column;
        top: 60px;
        padding: 8px;
    }
    
    .rtl .osm-search-box input[type="text"] {
        margin-bottom: 5px;
    }
    
    .rtl .osm-search-box .button {
        width: 100%;
        margin-bottom: 5px;
        margin-left: 0;
    }
    
    .rtl #osm-checkout-map {
        height: 400px !important;
    }
    
    .rtl #osm-address-display {
        max-width: 100%;
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
}

/* Loader Animation */
.rtl .loader-button {
    display: inline-block;
    animation: spin 1s infinite linear;
    font-size: 16px;
}

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

/* Map Provider Buttons */
.rtl .osm-map-links {
    margin-top: 15px;
}

.rtl .osm-map-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.rtl .osm-map-buttons a.button {
    background: #fff;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 10px 15px;
    border-radius: 5px;
    text-decoration: none;
    transition: all 0.2s;
}

.rtl .osm-map-buttons a.button:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/***********************************************
 * FIX FOR TRACKING PAGE DISPLAY ISSUES
 ***********************************************/

/* Force display on tracking page */
.rtl .osm-tracker-container {
    display: block !important;
    position: relative !important;
    min-height: 500px !important;
    width: 100% !important;
    margin: 25px 0 !important;
    z-index: 100 !important; 
    clear: both !important;
    overflow: visible !important;
}

.rtl .osm-tracker-form-wrapper {
    position: relative !important;
    width: 100% !important;
    margin-bottom: 20px !important;
    z-index: 20 !important;
}

.rtl #osm-tracker-form {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
    width: 100% !important;
}

.rtl #osm-tracker-form label {
    font-weight: 500 !important;
    margin-right: 0 !important;
    margin-left: 10px !important;
}

.rtl #osm-tracker-form input[type="number"] {
    width: 150px !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 3px !important;
    text-align: right !important;
    direction: rtl !important;
}

.rtl #osm-tracker-result {
    position: relative !important;
    width: 100% !important;
    min-height: 400px !important;
    margin-top: 20px !important;
    z-index: 20 !important;
}

.rtl #osm-tracker-map {
    width: 100% !important;
    height: 400px !important;
    z-index: 25 !important;
    position: relative !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.rtl .osm-tracker-container * {
    box-sizing: border-box !important;
}

.rtl .osm-tracker-container .leaflet-container {
    height: 400px !important;
    z-index: 30 !important;
}

.rtl #osm-tracker-form .button {
    padding: 8px 15px !important;
    height: auto !important;
    line-height: 1.5 !important;
}

/* Mobile responsiveness for tracker form */
@media screen and (max-width: 768px) {
    .rtl #osm-tracker-form {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .rtl #osm-tracker-form input[type="number"] {
        width: 100% !important;
    }
    
    .rtl #osm-tracker-form .button {
        width: 100% !important;
    }
}

/* Translations for Persian */
.rtl.fa-IR #osm-tracker-form label {
    font-family: 'IRANSans', 'Vazir', 'Tahoma', sans-serif !important;
}

.rtl.fa-IR .osm-tracker-container h3 {
    font-family: 'IRANSans', 'Vazir', 'Tahoma', sans-serif !important;
}