/**
 * ICH Poland - Region Selector Modal
 * Plik: assets/css/region-selector.css
 * Wersja: 1.2.0 - COMPACT
 */

:root {
    --ich-blue-dark: #1B4F7C;
    --ich-blue-light: #29B6D1;
    --ich-green: #7AB951;
    --ich-blue-hover: #164163;
    --ich-gray-light: #f8fafc;
    --ich-gray-border: #e2e8f0;
}

/* Modal Overlay */
.region-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(27, 79, 124, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 15px;
    backdrop-filter: blur(4px);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s, visibility 0.3s;
}

.region-modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Modal Container */
.region-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    max-width: 850px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    animation: regionModalSlideIn 0.3s ease-out;
}

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

/* Modal Header */
.region-modal-header {
    background: linear-gradient(135deg, var(--ich-blue-dark) 0%, #2a6a9e 100%);
    color: white;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.region-modal-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.region-modal-header h2 svg {
    width: 22px;
    height: 22px;
}

.region-modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.region-modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.region-modal-close svg {
    width: 18px;
    height: 18px;
}

/* Modal Body */
.region-modal-body {
    padding: 16px 20px;
}

/* ============================================
   BRANDING SECTION - COMPACT
   ============================================ */
.region-branding {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid var(--ich-blue-light);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.region-branding-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.region-logo-icon svg {
    display: block;
    width: 38px;
    height: 38px;
}

.region-logo-text {
    font-size: 1.4rem;
    color: var(--ich-blue-dark);
    font-weight: 400;
    line-height: 1.2;
}

.region-logo-text strong {
    font-weight: 700;
}

.region-branding-info {
    flex: 1;
    border-left: 2px solid var(--ich-blue-light);
    padding-left: 16px;
}

.region-branding-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ich-blue-dark);
    margin: 0 0 2px 0;
}

.region-branding-subtitle {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
    line-height: 1.3;
}

/* Subtitle */
.region-modal-subtitle {
    color: #64748b;
    margin-bottom: 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--ich-blue-light);
}

.region-modal-subtitle svg {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
}

/* Map Container */
.region-map-container {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--ich-gray-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#region-map {
    height: 300px;
    width: 100%;
    background: #e8f4f8;
}

/* Country Buttons */
.region-countries-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.region-country-btn {
    flex: 1;
    min-width: 180px;
    padding: 12px 14px;
    background: var(--ich-gray-light);
    border: 2px solid var(--ich-gray-border);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
}

.region-country-btn:hover {
    border-color: var(--ich-blue-light);
    background: #f0f9ff;
}

.region-country-btn.selected {
    border-color: var(--ich-green);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    box-shadow: 0 0 0 2px rgba(122, 185, 81, 0.2);
}

.region-country-btn .flag {
    font-size: 1.6rem;
    line-height: 1;
}

.region-country-btn .country-info {
    flex: 1;
}

.region-country-btn .country-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    margin: 0;
}

.region-country-btn .country-domain {
    font-size: 0.75rem;
    color: var(--ich-blue-light);
    font-family: monospace;
    margin: 0;
}

.region-country-btn .checkmark {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ich-green);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.region-country-btn .checkmark svg {
    width: 12px;
    height: 12px;
}

.region-country-btn.selected .checkmark {
    display: flex;
}

/* Modal Footer */
.region-modal-footer {
    padding: 14px 20px;
    background: var(--ich-gray-light);
    border-top: 1px solid var(--ich-gray-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.region-selected-info {
    color: #64748b;
    font-size: 0.85rem;
}

.region-selected-info strong {
    color: var(--ich-blue-dark);
}

.region-confirm-btn {
    background: linear-gradient(135deg, var(--ich-green) 0%, #69a344 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.region-confirm-btn svg {
    width: 18px;
    height: 18px;
}

.region-confirm-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(122, 185, 81, 0.4);
}

.region-confirm-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Trigger Button */
.region-trigger-btn {
    background: transparent;
    border: 2px solid var(--ich-blue-dark);
    color: var(--ich-blue-dark);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.region-trigger-btn:hover {
    background: var(--ich-blue-dark);
    color: white;
}

.region-trigger-btn .current-flag {
    font-size: 1.1rem;
}

/* Leaflet custom styles */
.region-modal .leaflet-container {
    font-family: inherit;
}

.region-modal .leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.region-modal .leaflet-popup-content {
    margin: 10px 14px;
}

.country-popup {
    text-align: center;
    min-width: 120px;
}

.country-popup .flag {
    font-size: 2rem;
    margin-bottom: 6px;
}

.country-popup .name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--ich-blue-dark);
    margin: 0;
}

.country-popup .domain {
    color: var(--ich-blue-light);
    font-family: monospace;
    font-size: 0.8rem;
    margin-top: 2px;
}

.country-popup .select-btn {
    margin-top: 10px;
    background: var(--ich-green);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    width: 100%;
    transition: background 0.2s;
    font-family: inherit;
}

.country-popup .select-btn:hover {
    background: #69a344;
}

/* Country label on map */
.country-flag-label {
    font-size: 1.6rem;
    text-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .region-modal {
        max-height: 95vh;
        margin: 10px;
        border-radius: 10px;
    }

    .region-modal-header {
        padding: 12px 16px;
    }

    .region-modal-header h2 {
        font-size: 1.05rem;
    }

    .region-modal-body {
        padding: 14px 16px;
    }

    .region-branding {
        flex-direction: column;
        text-align: center;
        padding: 14px;
        gap: 10px;
    }

    .region-branding-logo {
        justify-content: center;
    }

    .region-branding-info {
        border-left: none;
        border-top: 1px solid var(--ich-blue-light);
        padding-left: 0;
        padding-top: 10px;
    }

    .region-logo-text {
        font-size: 1.3rem;
    }

    #region-map {
        height: 240px;
    }

    .region-countries-list {
        flex-direction: column;
        gap: 8px;
    }

    .region-country-btn {
        min-width: 100%;
        padding: 10px 12px;
    }

    .region-modal-footer {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .region-confirm-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .region-modal-overlay {
        padding: 8px;
    }
    
    #region-map {
        height: 200px;
    }
    
    .region-country-btn .flag {
        font-size: 1.4rem;
    }

    .region-branding {
        padding: 12px;
    }

    .region-logo-icon svg {
        width: 32px;
        height: 32px;
    }

    .region-branding-title {
        font-size: 0.9rem;
    }

    .region-branding-subtitle {
        font-size: 0.75rem;
    }
}

/* Extra large screens - more compact */
@media (min-height: 800px) {
    #region-map {
        height: 320px;
    }
}

@media (max-height: 700px) {
    #region-map {
        height: 260px;
    }
    
    .region-branding {
        padding: 10px 14px;
    }
    
    .region-modal-body {
        padding: 12px 18px;
    }
    
    .region-countries-list {
        margin-top: 10px;
        gap: 8px;
    }
    
    .region-country-btn {
        padding: 10px 12px;
    }
}