/* ==========================================
   📝 APPLICATION-MODAL.CSS - CZYSTE KLASY BEM
   ========================================== */

/* Variables są ładowane przez functions.php jako zależność */

/* ==========================================
   🚪 MODAL OVERLAY
   ========================================== */

.portal-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--card-padding-md); /* 20px - Shape & Sizing System v4.0 */
}

/* ==========================================
   📦 MODAL CONTENT
   ========================================== */

.portal-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-card); /* 12px - Shape & Sizing System v4.0 (deprecated fix) */
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--card-padding-lg); /* 30px - Shape & Sizing System v4.0 */
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
}

/* ==========================================
   ❌ PRZYCISK ZAMKNIJ
   ========================================== */

.portal-modal__close {
    position: absolute;
    top: 30px;  /* Wyrównany z nagłówkiem */
    right: 20px;
    width: auto;
    min-width: 80px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm); /* 4px - Shape & Sizing System v4.0 (deprecated fix) */
    transition: var(--transition);
    z-index: 1;
    padding: 0 16px;
    font-family: inherit;
}

.portal-modal__close:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ==========================================
   📄 NAGŁÓWEK I PODTYTUŁ
   ========================================== */

.portal-modal__header {
    margin: 0 0 10px 0;
    padding: 0px 120px 0 0;  /* Więcej miejsca dla nowego przycisku Anuluj */
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
}

.portal-modal__subtitle {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 20px;
    margin-top: 0;
}

/* ==========================================
   📋 FORMULARZ
   ========================================== */

.portal-modal__form {
    margin-top: 20px;
}

.portal-modal__field {
    margin-bottom: 20px;
}

.portal-modal__label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.portal-modal__input,
.portal-modal__textarea,
.portal-modal__file {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); /* 4px - Shape & Sizing System v4.0 (deprecated fix) */
    font-size: 14px;
    box-sizing: border-box;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

.portal-modal__input:focus,
.portal-modal__textarea:focus,
.portal-modal__file:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.portal-modal__textarea {
    resize: vertical;
    min-height: 100px;
}

/* ==========================================
   🔘 PRZYCISKI AKCJI
   ========================================== */

.portal-modal__actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.portal-modal__btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-sm); /* 4px - Shape & Sizing System v4.0 (deprecated fix) */
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    min-width: 120px;
    transition: var(--transition);
    border: 1px solid;
    font-family: inherit;
    line-height: 1.2;
    background: none; /* Reset WordPress styles */
}

.portal-modal__btn--cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.portal-modal__btn--cancel:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.portal-modal__btn--submit {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.portal-modal__btn--submit:hover {
    background: var(--success-color-hover);
    border-color: var(--success-color-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ==========================================
   📱 RESPONSIVE DESIGN
   ========================================== */

/* Tablet */
@media (max-width: 768px) {
    .portal-modal-content {
        padding: var(--card-padding-md); /* 20px - Shape & Sizing System v4.0 */
        max-width: 95%;
    }
    
    .portal-modal__close {
        top: 20px;
        right: 20px;
        min-width: 70px;
        height: 32px;
        font-size: 13px;
        padding: 0 12px;
    }
    
    .portal-modal__header {
        font-size: 20px;
        padding: 20px 140px 0px 0px;
        margin: 0px -5px 0px 0px;
    }
    
    .portal-modal__label {
        font-size: 13px;
    }
    
    .portal-modal__input,
    .portal-modal__textarea,
    .portal-modal__file {
        padding: 12px;
        font-size: 16px; /* Zapobiega zoom na iOS */
    }
}

/* Tablet (820x1180, iPad Air, itp.) */
@media (max-width: 900px) {
    .portal-modal__header {
        font-size: 21px;
        padding: 0px 130px 0px 0px;
        margin-left: -5px;
        margin-top: -10px;
    }
    
    .portal-modal__close {
        top: 20px;
        right: 30px;
        min-width: 75px;
        height: 34px;
        font-size: 13px;
        padding: 0 14px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .portal-modal-overlay {
        padding: var(--input-padding-y); /* 10px - Shape & Sizing System v4.0 */
    }
    
    .portal-modal-content {
        padding: var(--input-padding-x); /* 15px - Shape & Sizing System v4.0 */
        max-width: 100%;
    }
    
    .portal-modal__header {
        margin: -10px 0 20px 0;
        font-size: 18px;
        padding: 10px 85px 0 0;  /* Połączone właściwości */
    }
    
    /* Przyciski pionowo na mobile */
    .portal-modal__actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .portal-modal__btn {
        width: 100%;
        min-width: auto;
    }
    
    .portal-modal__input,
    .portal-modal__textarea,
    .portal-modal__file {
        font-size: 16px; /* Zapobiega zoom na iOS */
    }
}

/* ==========================================
   🌙 DARK MODE SUPPORT
   ========================================== */

html[data-theme="dark"] .portal-modal__btn--cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html[data-theme="dark"] .portal-modal__btn--cancel:hover {
    background: var(--bg-hover);
}

/* ==========================================
   🎯 ACCESSIBILITY
   ========================================== */

.portal-modal__btn:focus,
.portal-modal__close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.portal-modal__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
   🔧 WORDPRESS RESET - OSTATECZNE
   ========================================== */

/* Super specyficzne resetowanie WordPress/Astra theme */
.portal-modal-overlay .portal-modal__btn,
.portal-modal-content .portal-modal__btn {
    /* Nadpisz WordPress button styles */
    font-family: inherit !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    padding: 12px 16px !important;
    margin: 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Reset tylko dla naszego modala - bez wpływu na resztę */
.portal-modal-overlay * {
    box-sizing: border-box;
}

/* ==========================================
   📱 MOBILE WORDPRESS RESET - PRZYCISK ANULUJ
   ========================================== */

/* WordPress reset - Mobile specyficzny (przebija słabszy selektor) */
@media (max-width: 480px) {
    .portal-modal-overlay .portal-modal-content .portal-modal__close {
        position: absolute;
        top: 10px;
        right: 16px;
        width: auto;
        min-width: 60px;
        max-width: 80px;
        height: 28px;
        flex: none;
        flex-shrink: 0;
        padding: 0 8px;
        margin: 0;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 600;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        cursor: pointer;
        color: var(--text-primary);
        border-radius: var(--radius-sm); /* 4px - Shape & Sizing System v4.0 (deprecated fix) */
        transition: var(--transition);
        z-index: 1;
        font-family: inherit;
    }
    
    /* Hover effect dla mobile */
    .portal-modal-overlay .portal-modal-content .portal-modal__close:hover {
        background: var(--bg-hover);
        border-color: var(--border-strong);
        transform: translateY(-1px);
        box-shadow: var(--shadow-sm);
    }
}