/* Scoped styles for Moje Kontakty module within HELPio */

.moje-kontakty-widget {
    /* Lokalne zmienne, aby nie kolidować z globalnymi */
    --mk-primary: #2563eb;
    --mk-primary-dark: #1d4ed8;
    --mk-secondary: #64748b;
    --mk-danger: #ef4444;
    --mk-success: #22c55e;
    --mk-bg-light: #f1f5f9;
    --mk-surface: #ffffff;
    --mk-text-main: #1e293b;
    --mk-text-muted: #64748b;
    --mk-border: #e2e8f0;

    /* Ustawienia kontenera wewnątrz layoutu HELPio */
    width: 100%;
    max-width: 100%;
    font-family: inherit;
    /* Dziedziczenie czcionki z HELPio */
}

/* Główna karta aplikacji */
.mk-app-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--mk-surface);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    /* Minimalna wysokość, zamiast 100vh, aby pasowało do layoutu */
    min-height: 600px;
    overflow: hidden;
    border: 1px solid var(--mk-border);
    display: none;
    /* Hidden by default for security check */
}

/* Header */
.mk-app-header {
    padding: 20px;
    border-bottom: 1px solid var(--mk-border);
    background: var(--mk-surface);
}

.mk-controls-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* Search Box */
.mk-search-box {
    flex: 1;
    position: relative;
}

.mk-search-box input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--mk-border);
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.mk-search-box input:focus {
    border-color: var(--mk-primary);
}

.mk-search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--mk-text-muted);
}

/* Przyciski */
.mk-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, opacity 0.2s;
    font-size: 14px;
}

.mk-btn-primary {
    background: var(--mk-primary);
    color: white;
}

.mk-btn-primary:hover {
    background: var(--mk-primary-dark);
}

.mk-btn-secondary {
    background: var(--mk-bg-light);
    color: var(--mk-text-main);
}

.mk-btn-secondary:hover {
    background: #e2e8f0;
}

.mk-btn-danger {
    background: var(--mk-danger);
    color: white;
}

.mk-btn-danger:hover {
    opacity: 0.9;
}

.mk-btn-icon {
    padding: 10px;
}

.mk-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Chips Kategorii */
.mk-categories-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: thin;
}

.mk-chip {
    padding: 6px 12px;
    background: var(--mk-bg-light);
    border-radius: 16px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    color: var(--mk-text-main);
}

.mk-chip.active {
    background: var(--mk-primary);
    color: white;
}

.mk-chip.custom-chip {
    border-color: var(--mk-border);
}

/* Lista Kontaktów */
.mk-contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8fafc;
    /* Lekko szare tło dla listy */
}

.mk-contact-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border: 1px solid var(--mk-border);
    border-radius: 12px;
    margin-bottom: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mk-contact-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.mk-contact-avatar {
    width: 50px;
    height: 50px;
    background: var(--mk-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    margin-right: 15px;
    flex-shrink: 0;
}

.mk-contact-info {
    flex: 1;
    overflow: hidden;
    /* Dla długich nazw */
}

.mk-contact-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
    color: var(--mk-text-main);
}

.mk-contact-meta {
    font-size: 14px;
    color: var(--mk-text-muted);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.mk-contact-category {
    background: var(--mk-bg-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.mk-contact-actions {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

/* Modale */
.mk-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    /* Musi być wyżej niż elementy HELPio */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}

.mk-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mk-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: mkModalSlideIn 0.3s ease-out;
}

@keyframes mkModalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mk-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.mk-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--mk-text-main);
    margin: 0;
}

.mk-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--mk-text-muted);
    padding: 5px;
}

.mk-form-group {
    margin-bottom: 16px;
}

.mk-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--mk-text-main);
}

.mk-form-group input,
.mk-form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--mk-border);
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
}

.mk-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Zarządzanie kategoriami w modalu */
.mk-category-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--mk-border);
}

.mk-category-list-item:last-child {
    border-bottom: none;
}

.mk-badge-locked {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    text-transform: uppercase;
}