/* ==========================================================================
   SETTINGS TAB STYLES - MenuList Application
   ========================================================================== */

.settings-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Паролата и имейлът - един до друг, еднакво широки */
.settings-security-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: stretch;
}

/* Card Styles */
.profile-info-card,
.security-card {
    background: white;
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(212, 165, 116, 0.15);
}

.security-card { display: flex; flex-direction: column; }
.security-card .form-fields { flex: 1; }
.security-card .change-password-btn,
.security-card .change-email-btn { margin-top: auto; }

.card-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1ece6;
}

/* Иконите са Font Awesome в плочка. Старият градиент през background-clip:text
   превръщаше емоджитата в кафяви силуети. */
.card-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #faf3eb;
    color: #b8834f;
    font-size: 1.15rem;
}

.card-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
}

/* Profile Details - плочки в мрежа */
.profile-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-width: 0;
    padding: 0.875rem 1rem;
    background: #fbf8f4;
    border-radius: 12px;
    border: 1px solid rgba(212, 165, 116, 0.18);
}

.detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #8a7a6a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    max-width: 100%;
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    overflow-wrap: anywhere;
}

.detail-value.badge {
    padding: 0.25rem 0.75rem !important;
    font-size: 0.75rem !important;
}

.detail-value.role-user {
    background: linear-gradient(135deg, #d4a574 0%, #c49464 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value.role-manager {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value.role-administrator {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value.status-active {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
/* Form Fields */
.form-fields {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-group input {
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.field-group input:focus {
    outline: none;
    border-color: #d4a574;
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.field-group input[readonly] {
    background: #f7fafc;
    color: #718096;
    cursor: not-allowed;
}

.field-note {
    font-size: 0.75rem;
    color: #718096;
    font-style: italic;
}

/* Buttons */
.change-password-btn,
.change-email-btn {
    background: linear-gradient(135deg, #d4a574 0%, #c49464 100%);
    color: white;
    border: 2px solid transparent;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.4);
    margin-top: 1.5rem;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.change-password-btn::before,
.change-email-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.change-password-btn:hover::before,
.change-email-btn:hover::before {
    left: 100%;
}

.change-password-btn:hover,
.change-email-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(212, 165, 116, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

.change-password-btn:active,
.change-email-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.6);
}

.btn-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Responsive Design */
@media (max-width: 900px) {
    .settings-security-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .settings-container,
    .settings-security-row {
        gap: 1rem;
    }

    .profile-details {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .profile-details {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* На телефон плочката е ред: етикет вляво, стойност вдясно - шест
       плочки една под друга иначе изяждат цял екран. */
    .detail-row {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 0.65rem 0.875rem;
    }

    .detail-label {
        white-space: nowrap;
        font-size: 0.68rem;
    }

    .detail-value {
        min-width: 0;
        text-align: right;
        font-size: 0.85rem;
    }

    /* Имейлът е дълъг - етикетът отгоре, стойността отдолу, без да се реже. */
    .detail-row.detail-wide {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .detail-row.detail-wide .detail-value {
        text-align: left;
    }

    .profile-info-card,
    .security-card {
        padding: 1.5rem;
    }

    .card-header h2 {
        font-size: 1.25rem;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-main {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-tabs {
        flex-direction: column;
        gap: 0;
    }
    
    .tab-btn {
        border-radius: 0;
        text-align: center;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .code-tabs {
        flex-direction: column;
        gap: 0;
    }
    
    .code-tab {
        border-radius: 0;
        text-align: center;
    }
}

/* --- Алергени (allergen-settings.js, флаг `allergens`) ------------------- */
#allergenSettingsMount:empty { display: none; }
.allergen-settings-card { margin: 0; }
.allergen-pref-hint { margin: 0 0 14px; font-size: 14px; color: #64748b; line-height: 1.5; }
.allergen-pref-list { display: flex; flex-direction: column; gap: 8px; }
.allergen-pref-row {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}
.allergen-pref-name { font-weight: 600; color: #1e293b; }
.allergen-pref-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #334155; cursor: pointer; }
.allergen-pref-toggle input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: #f97316; cursor: pointer; }
.allergen-pref-status { min-height: 18px; margin-top: 8px; font-size: 13px; color: #16a34a; }
@media (max-width: 600px) {
    .allergen-pref-row { grid-template-columns: 1fr; gap: 8px; }
}

/* Превключвател (toggle switch) вместо отметка. Остава истински checkbox
   (role="switch") - клавиатура, четци на екрана и `change` работят както преди. */
.allergen-pref-toggle input.allergen-switch {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 26px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #d9dde3;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.allergen-pref-toggle input.allergen-switch::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.allergen-pref-toggle input.allergen-switch:checked {
    background: #34c759;
}

.allergen-pref-toggle input.allergen-switch:checked::before {
    transform: translateX(18px);
}

.allergen-pref-toggle input.allergen-switch:focus-visible {
    outline: 2px solid #b8834f;
    outline-offset: 2px;
}

.allergen-pref-toggle { gap: 10px; }
.allergen-pref-row { gap: 20px; }

/* Превключвателите стоят в колони - иначе редът на „Копирай текста" с по-дългия
   етикет ги измества и не се подравняват с горните. */
@media (min-width: 601px) {
    .allergen-pref-row { grid-template-columns: minmax(140px, 1fr) 190px 210px; }
}

/* --- Профилът като тънка лента (27.09.2026) ------------------------------ */
.profile-strip {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.5rem;
}

.profile-avatar {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #faf3eb;
    color: #b8834f;
    font-size: 1.2rem;
}

.profile-main { flex: 1 1 auto; min-width: 0; }

.profile-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
    line-height: 1.3;
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin-top: 0.2rem;
    font-size: 0.875rem;
    color: #64748b;
}

.profile-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.profile-meta-item i { color: #c49464; font-size: 0.8rem; }

.sr-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.profile-badges {
    flex: 0 0 auto;
    display: flex;
    gap: 0.5rem;
}

/* Иконата в бутоните е само глиф - глобалното `.btn-icon` я слагаше в бяла плочка. */
.change-password-btn .btn-icon,
.change-email-btn .btn-icon {
    background: none;
    padding: 0;
    width: auto;
    height: auto;
    box-shadow: none;
    color: inherit;
    font-size: 1rem;
    filter: none;
}

@media (max-width: 600px) {
    .profile-strip {
        flex-wrap: wrap;
        padding: 1rem;
    }

    .profile-badges {
        width: 100%;
        padding-left: calc(48px + 1rem);
    }

    .profile-meta {
        flex-direction: column;
        gap: 0.2rem;
    }
}

/* Подредбата е закотвена към #settings с по-висока специфичност, за да не я
   пребие общ стил от друг таб (напр. `.detail-row` в sales-funnel.css и
   articles.css, които се зареждат за цялото табло). */
#settings .settings-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    text-align: left;
}

#settings .settings-container > * { width: 100%; min-width: 0; }

#settings .settings-security-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

#settings .card-header { justify-content: flex-start; text-align: left; }

@media (max-width: 900px) {
    #settings .settings-security-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    #settings .settings-container,
    #settings .settings-security-row { gap: 1rem; }
}

/* --- Автоматично разпознаване на алергени (allergen-settings.js) -------- */
.allergen-detect-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    background: #fbf8f4;
    border: 1px dashed rgba(196, 148, 100, 0.55);
}
.allergen-detect-text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.allergen-detect-text strong { color: #2d3748; font-size: 0.95rem; }
.allergen-detect-text span { color: #64748b; font-size: 0.85rem; line-height: 1.45; }
.allergen-detect-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; flex: 0 0 auto; }
.allergen-detect-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    min-height: 0; padding: 0.7rem 1.1rem; border: 0; border-radius: 10px;
    background: linear-gradient(135deg, #d4a574 0%, #c49464 100%); color: #fff;
    font-weight: 700; font-size: 0.9rem; cursor: pointer; white-space: nowrap;
}
.allergen-detect-btn:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; }
.allergen-detect-link {
    min-height: 0; padding: 0; border: 0; background: none;
    color: #b8834f; font-size: 0.8rem; text-decoration: underline; cursor: pointer;
}
.allergen-detect-link[hidden] { display: none; }

.allergen-detect-overlay {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(15, 23, 42, 0.45);
}
.allergen-detect-modal {
    display: flex; flex-direction: column;
    width: 100%; max-width: 720px; max-height: min(88vh, 900px);
    background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.allergen-detect-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid #f1ece6; }
.allergen-detect-head h3 { margin: 0; font-size: 1.1rem; color: #2d3748; display: flex; gap: 0.5rem; align-items: center; }
.allergen-detect-head h3 i { color: #c49464; }
.allergen-detect-close { min-height: 0; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f7f3ee; font-size: 1.4rem; line-height: 1; cursor: pointer; color: #64748b; }
.allergen-detect-note { margin: 0; padding: 0.85rem 1.25rem; font-size: 0.85rem; line-height: 1.5; color: #64748b; background: #fffaf3; }
.allergen-detect-list { flex: 1 1 auto; overflow-y: auto; padding: 0.5rem 1.25rem; }
.allergen-detect-row { padding: 0.7rem 0; border-bottom: 1px solid #f1f5f9; }
.allergen-detect-name { font-weight: 600; color: #1e293b; margin-bottom: 0.4rem; }
.allergen-detect-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.allergen-detect-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 999px;
    font-size: 0.82rem; color: #334155; cursor: pointer; user-select: none;
}
.allergen-detect-chip input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: #f97316; }
.allergen-detect-chip b { color: #64748b; }
.allergen-detect-chip small { color: #94a3b8; font-size: 0.72rem; }
.allergen-detect-chip:has(input:checked) { background: #fff7ed; border-color: #f97316; }
.allergen-detect-empty { color: #64748b; font-size: 0.9rem; }
.allergen-detect-foot { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 0.9rem 1.25rem; border-top: 1px solid #f1ece6; }
.allergen-detect-foot button { min-height: 0; padding: 0.65rem 1.1rem; border-radius: 10px; font-weight: 600; cursor: pointer; }
.allergen-detect-cancel { border: 1px solid #e2e8f0; background: #fff; color: #475569; }
.allergen-detect-save { border: 0; background: linear-gradient(135deg, #d4a574 0%, #c49464 100%); color: #fff; }
.allergen-detect-save:disabled { opacity: 0.6; cursor: wait; }

@media (max-width: 600px) {
    .allergen-detect-box { flex-direction: column; align-items: stretch; }
    .allergen-detect-actions { align-items: stretch; }
    .allergen-detect-btn { justify-content: center; }
    .allergen-detect-overlay { padding: 0; align-items: flex-end; }
    .allergen-detect-modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
}

/* Дисклеймър в прозореца за разпознаване - записът е заключен до отметката. */
.allergen-detect-disclaimer { padding: 0.85rem 1.25rem; border-top: 1px solid #f1ece6; background: #fff7ed; }
.allergen-detect-disclaimer p { margin: 0 0 0.6rem; font-size: 0.85rem; line-height: 1.5; color: #7c2d12; }
.allergen-detect-disclaimer p i { color: #ea580c; }
.allergen-detect-ack { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.85rem; font-weight: 600; color: #1e293b; cursor: pointer; }
.allergen-detect-ack input { flex: 0 0 auto; width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: #f97316; }
.allergen-detect-save:disabled { opacity: 0.45; cursor: not-allowed; }
