/**
 * Currency Converter CSS for Resto M2 Plugin
 * Version: 1.0.0
 */

/* Currency Converter Widget Styles */
.resto-currency-selector {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.resto-currency-selector:hover {
    border-color: #007cba;
}

.resto-currency-selector:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Currency Buttons Style */
.resto-currency-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.resto-currency-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    text-align: center;
}

.resto-currency-btn:hover {
    border-color: #007cba;
    background: #f8f9fa;
}

.resto-currency-btn.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* Currency Tabs Style */
.resto-currency-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    gap: 0;
}

.resto-currency-tab {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-bottom: none;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #666;
    border-radius: 4px 4px 0 0;
    margin-right: -1px;
}

.resto-currency-tab:hover {
    background: #e9ecef;
    color: #333;
}

.resto-currency-tab.active {
    background: white;
    color: #007cba;
    border-bottom: 1px solid white;
    margin-bottom: -1px;
    font-weight: 600;
}

/* Currency Toggle Style */
.resto-currency-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
}

.resto-currency-toggle .currency-from,
.resto-currency-toggle .currency-to {
    font-weight: 600;
    color: #333;
}

.resto-currency-toggle .toggle-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #007cba;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.resto-currency-toggle .toggle-btn:hover {
    background: #f0f8ff;
}

/* Floating Currency Widget */
.resto-currency-floating {
    position: fixed;
    z-index: 9999;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.resto-currency-floating:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Inline Currency Widget */
.resto-menu-item .resto-currency-selector,
.resto-menu-item .resto-currency-buttons {
    margin-top: 8px;
    font-size: 12px;
}

.resto-menu-item .resto-currency-btn {
    padding: 4px 8px;
    font-size: 12px;
    min-width: 40px;
}

/* Admin Currency Selector */
.currency-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.currency-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.currency-option:hover {
    border-color: #007cba;
    background: #f8f9fa;
}

.currency-option input[type="checkbox"] {
    margin: 0;
}

.currency-option input[type="checkbox"]:checked + .currency-flag + .currency-info {
    color: #007cba;
    font-weight: 600;
}

.currency-flag {
    font-size: 20px;
    line-height: 1;
}

.currency-info {
    flex: 1;
}

.currency-info strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.currency-info small {
    color: #666;
    font-size: 12px;
}

/* Rates Table */
.rates-table {
    margin-top: 20px;
}

.rates-table table {
    width: 100%;
    border-collapse: collapse;
}

.rates-table th,
.rates-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.rates-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.rates-table td {
    color: #666;
}

/* Manual Rates */
.manual-rates {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.rate-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8f9fa;
}

.rate-input label {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

.rate-input input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.rate-input span {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* API Status */
.api-status {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid #007cba;
}

.api-status p {
    margin: 0 0 10px 0;
    color: #666;
}

.api-status p:last-of-type {
    margin-bottom: 15px;
}

/* Currency Preview */
.currency-preview {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.sample-menu-item {
    background: white;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sample-menu-item h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 18px;
}

.sample-menu-item p {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 14px;
}

.item-price-with-currency {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.base-price {
    font-size: 18px;
    font-weight: bold;
    color: #007cba;
}

.currency-converter-widget {
    transition: opacity 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    .resto-currency-floating {
        /* Keep corner-anchored; do NOT inset all four sides (causes full-screen stretch on fixed). */
        /* JS inline style sets top/right; only override padding here.                          */
        left: auto !important;
        bottom: auto !important;
        width: auto;
        max-width: 180px;
        padding: 10px;
    }
    
    .resto-currency-buttons {
        justify-content: center;
    }
    
    .resto-currency-tabs {
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .resto-currency-tab {
        flex-shrink: 0;
    }
    
    .currency-selector {
        grid-template-columns: 1fr;
    }
    
    .manual-rates {
        grid-template-columns: 1fr;
    }
    
    .item-price-with-currency {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .resto-currency-selector,
    .resto-currency-btn,
    .resto-currency-toggle {
        background: #2d2d2d;
        border-color: #555;
        color: #fff;
    }
    
    .resto-currency-btn:hover {
        background: #3d3d3d;
    }
    
    .resto-currency-btn.active {
        background: #007cba;
        border-color: #007cba;
    }
    
    .resto-currency-floating {
        background: #2d2d2d;
        border-color: #555;
    }
    
    .currency-option {
        background: #2d2d2d;
        border-color: #555;
        color: #fff;
    }
    
    .currency-option:hover {
        background: #3d3d3d;
    }
}

/* Animation Effects */
.resto-currency-selector,
.resto-currency-btn,
.resto-currency-tab {
    transition: all 0.2s ease;
}

.resto-currency-floating {
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading State */
.currency-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.currency-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error State */
.currency-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
}

/* Success State */
.currency-success {
    color: #28a745;
    font-size: 12px;
    margin-top: 4px;
}

/* =====================================================================
   THEME FORM-STYLER DEFENSE
   Some themes (WoodMart/pubzinne) wrap every <select> in a
   .select_container and hide the native element, leaving a blank box
   when the theme-side label is not populated (as with dynamic JS widgets).
   These rules ensure the native select inside our floating widget is
   always visible and correctly sized regardless of theme interference.
   ===================================================================== */

/* Force the native select to be visible inside our widget */
.resto-currency-floating .resto-currency-selector,
.resto-currency-floating select.resto-currency-selector {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    appearance: auto !important;
    -webkit-appearance: auto !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
    clip-path: none !important;
    font-size: 13px;
    padding: 4px 6px;
    background: white;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

/* Hide the theme-generated wrapper/label if it appears inside our widget,
   so only the native select shows */
.resto-currency-floating .select_container > span,
.resto-currency-floating .select_container > .select_trigger,
.resto-currency-floating .wd-select-container > span {
    display: none !important;
}

/* If the theme moved our native select off-screen inside .select_container,
   bring it back */
.resto-currency-floating .select_container {
    position: static !important;
    display: block !important;
}
.resto-currency-floating .select_container select {
    position: static !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
    clip-path: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Neutralise the theme pseudo-elements that overlay the selected value.
   ::before renders a solid colour box (krem/rgb(239,237,232)) covering
   the native select text; ::after adds a redundant theme arrow that
   conflicts with appearance:auto's native arrow. Both must be gone. */
.resto-currency-floating .select_container::before,
.resto-currency-floating .select_container::after {
    display: none !important;
    content: none !important;
    background: transparent !important;
}