/**
 * WePresta VAT Preview - Front-office Styles
 * 
 * @author    WePresta <mail@wepresta.shop>
 * @copyright Since 2024 WePresta
 * @license   AFL-3.0
 */

/* =========================================================================
   CSS VARIABLES - Customizable theme colors
   ========================================================================= */

:root {
    --wepresta-primary: #25b9d7;
    --wepresta-primary-rgb: 37, 185, 215;
    --wepresta-text: #333;
    --wepresta-text-muted: #666;
    --wepresta-border: #ddd;
    --wepresta-bg-light: #f8f9fa;
    --wepresta-bg-hover: #e9ecef;
    --wepresta-radius: 4px;
    --wepresta-font-size: 13px;
    --wepresta-success: #28a745;
    --wepresta-warning: #ffc107;
    --wepresta-info-bg: linear-gradient(135deg, #e8f4f8 0%, #d4edfa 100%);
}

/* =========================================================================
   COUNTRY SELECTOR
   ========================================================================= */

.wepresta-vat-selector {
    display: inline-flex;
    align-items: center;
    font-size: var(--wepresta-font-size, 13px);
    font-family: inherit;
}

.vat-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vat-selector-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--wepresta-text-muted);
    margin: 0;
    font-weight: 500;
}

.vat-selector-label .wepresta-icon {
    width: 16px;
    height: 16px;
}

.vat-selector-label .label-text {
    display: none;
}

@media (min-width: 768px) {
    .vat-selector-label .label-text {
        display: inline;
    }
}

.vat-selector-dropdown {
    display: flex;
    align-items: center;
    gap: 4px;
}

.vat-country-select {
    padding: 6px 10px;
    border: 1px solid var(--wepresta-border);
    border-radius: var(--wepresta-radius, 4px);
    background: var(--wepresta-bg-light, #fff);
    color: var(--wepresta-text, #333);
    font-size: var(--wepresta-font-size, 13px);
    cursor: pointer;
    min-width: 150px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.vat-country-select:hover {
    border-color: var(--wepresta-primary);
}

.vat-country-select:focus {
    outline: none;
    border-color: var(--wepresta-primary);
    box-shadow: 0 0 0 3px rgba(var(--wepresta-primary-rgb), 0.15);
}

.vat-delivery-text {
    padding: 6px 10px;
    font-size: var(--wepresta-font-size, 13px);
    color: var(--wepresta-text);
}

/* (removed) legacy reset/source UI */

/* =========================================================================
   CUSTOM INLINE / MODAL WIDGET (template system)
   ========================================================================= */

.wepresta-vat-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--wepresta-border);
    border-radius: var(--wepresta-radius, 4px);
    background: var(--wepresta-bg-light, #fff);
    color: var(--wepresta-text, #333);
    font-size: var(--wepresta-font-size, 13px);
    cursor: pointer;
    line-height: 1.2;
}

.wepresta-vat-trigger:hover {
    border-color: var(--wepresta-primary);
}

.wepresta-vat-trigger:focus {
    outline: none;
    border-color: var(--wepresta-primary);
    box-shadow: 0 0 0 3px rgba(var(--wepresta-primary-rgb), 0.15);
}

.wepresta-vat-caret {
    color: var(--wepresta-text-muted);
    font-size: 11px;
}

.wepresta-vat-dropdown {
    position: fixed;
    z-index: 999999;
    min-width: 240px;
    max-width: 360px;
    max-height: 320px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--wepresta-border);
    border-radius: calc(var(--wepresta-radius, 4px) + 2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.wepresta-vat-list {
    list-style: none;
    margin: 0;
    padding: 6px;
}

.wepresta-vat-option {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: calc(var(--wepresta-radius, 4px) + 2px);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-size: var(--wepresta-list-font-size, var(--wepresta-font-size, 13px));
    color: var(--wepresta-text, #333);
}

.wepresta-vat-option:hover,
.wepresta-vat-option:focus {
    background: var(--wepresta-bg-hover);
    outline: none;
}

.wepresta-vat-option-right {
    color: var(--wepresta-primary);
    font-weight: 700;
    white-space: nowrap;
}

.wepresta-vat-inline-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.wepresta-vat-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.wepresta-vat-modal {
    width: min(720px, 100%);
    max-height: min(80vh, 720px);
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--wepresta-border);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wepresta-vat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--wepresta-border);
}

.wepresta-vat-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--wepresta-text, #333);
}

.wepresta-vat-modal-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--wepresta-border);
    border-radius: 10px;
    background: var(--wepresta-bg-light, #fff);
    cursor: pointer;
    color: var(--wepresta-text-muted, #666);
}

.wepresta-vat-modal-close:hover {
    border-color: var(--wepresta-primary);
    color: var(--wepresta-primary);
}

.wepresta-vat-modal-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--wepresta-border);
}

.wepresta-vat-modal-body {
    padding: 12px 12px 14px 12px;
    overflow: auto;
}

.wepresta-vat-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 576px) {
    .wepresta-vat-modal-grid {
        grid-template-columns: 1fr;
    }
}

.vat-source-badge--manual {
    background: rgba(var(--wepresta-primary-rgb), 0.1);
    color: var(--wepresta-primary);
}

.vat-source-badge--auto {
    background: #e9ecef;
    color: #6c757d;
}

.vat-source-badge--default {
    background: #f8f9fa;
    color: #999;
}

.vat-source-badge .wepresta-icon {
    width: 12px;
    height: 12px;
}

.wepresta-vat-selector.loading {
    opacity: 0.6;
    pointer-events: none;
}

.wepresta-vat-selector.loading .vat-country-select {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%2325b9d7"><path d="M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8Z"><animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="1s" repeatCount="indefinite"/></path></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}

/* =========================================================================
   DISCLAIMER
   ========================================================================= */

.wepresta-vat-disclaimer {
    position: relative;
    margin: 15px 0;
    padding: 12px 40px 12px 15px;
    background: var(--wepresta-info-bg);
    border-left: 4px solid var(--wepresta-primary);
    border-radius: 4px;
    font-size: 13px;
    color: var(--wepresta-text);
    animation: weprestaSlideIn 0.3s ease-out;
}

.disclaimer-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.disclaimer-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--wepresta-primary);
}

.disclaimer-text {
    line-height: 1.5;
    flex: 1;
}

.disclaimer-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #999;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.disclaimer-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

.disclaimer-close .wepresta-icon {
    width: 14px;
    height: 14px;
}

/* Dark theme variant */
.wepresta-vat-disclaimer.wepresta-vat-disclaimer--dark {
    background: linear-gradient(135deg, #2d3e50 0%, #1e2f40 100%);
    border-left-color: #3498db;
    color: #ecf0f1;
}

.wepresta-vat-disclaimer--dark .disclaimer-icon {
    color: #3498db;
}

/* Compact variant for product pages */
.wepresta-vat-disclaimer.wepresta-vat-disclaimer--compact {
    padding: 8px 32px 8px 12px;
    margin: 10px 0;
    font-size: 12px;
}

.wepresta-vat-disclaimer--compact .disclaimer-icon {
    width: 16px;
    height: 16px;
}

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

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

.wepresta-vat-disclaimer.hiding {
    animation: weprestaSlideOut 0.2s ease-out forwards;
}

/* =========================================================================
   TOAST NOTIFICATIONS
   ========================================================================= */

.wepresta-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.wepresta-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    color: var(--wepresta-text);
    pointer-events: auto;
    animation: weprestaToastIn 0.3s ease-out;
    max-width: 320px;
}

.wepresta-toast.hiding {
    animation: weprestaToastOut 0.2s ease-out forwards;
}

.wepresta-toast--success {
    border-left: 4px solid var(--wepresta-success);
}

.wepresta-toast--success .wepresta-toast-icon {
    color: var(--wepresta-success);
}

.wepresta-toast--error {
    border-left: 4px solid #dc3545;
}

.wepresta-toast--error .wepresta-toast-icon {
    color: #dc3545;
}

.wepresta-toast--info {
    border-left: 4px solid var(--wepresta-primary);
}

.wepresta-toast--info .wepresta-toast-icon {
    color: var(--wepresta-primary);
}

.wepresta-toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.wepresta-toast-message {
    flex: 1;
    line-height: 1.4;
}

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

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

/* =========================================================================
   CHECKOUT WARNING
   ========================================================================= */

.wepresta-checkout-warning {
    animation: shakeX 0.5s ease-out;
}

@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* =========================================================================
   ADDRESS COUNTRY MESSAGE (CHECKOUT / ADDRESS FORMS)
   ========================================================================= */

.wepresta-vat-address-country-message {
    margin-top: 6px;
    color: #6c757d;
    line-height: 1.3;
}

.wepresta-vat-address-country-message--info {
    color: #0c5460;
}

.wepresta-vat-address-country-message--warning {
    color: #856404;
}

select.wepresta-vat-country-locked {
    opacity: 0.8;
    cursor: not-allowed !important;
}

/* =========================================================================
   CHECKOUT NOTICE
   ========================================================================= */

.vatpreview-checkout-notice {
    margin: 15px 0;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 576px) {
    .wepresta-vat-selector {
        width: 100%;
    }
    
    .vat-selector-wrapper {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .vat-country-select {
        min-width: unset;
        flex: 1;
    }
    
    .wepresta-vat-disclaimer {
        font-size: 12px;
        padding: 10px;
    }
    
    .wepresta-checkout-warning {
        font-size: 13px;
    }
}

/* =========================================================================
   ACCESSIBILITY - Screen reader only
   ========================================================================= */

.sr-only,
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* =========================================================================
   FOCUS VISIBLE - Keyboard navigation
   ========================================================================= */

.vat-country-select:focus-visible,
.disclaimer-close:focus-visible {
    outline: 2px solid var(--wepresta-primary);
    outline-offset: 2px;
}

/* =========================================================================
   PRINT STYLES
   ========================================================================= */

@media print {
    .wepresta-vat-selector,
    .wepresta-vat-disclaimer,
    .wepresta-checkout-warning,
    .wepresta-toast-container {
        display: none !important;
    }
}

/* =========================================================================
   HIGH CONTRAST MODE
   ========================================================================= */

@media (prefers-contrast: high) {
    .wepresta-vat-disclaimer {
        border-left-width: 6px;
    }
    
    .vat-country-select {
        border-width: 2px;
    }
}

