/* ============================================
   HEADER COMPONENT STYLES
   ============================================ */

/* Hide translatable content until i18n is ready to prevent language flash */
body:not(.i18n-ready) [data-i18n],
body:not(.i18n-ready) .lang-code {
    opacity: 0;
}
body.i18n-ready [data-i18n],
body.i18n-ready .lang-code {
    opacity: 1;
    transition: opacity 0.1s ease-in;
}

header {
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
    letter-spacing: 0.05em;
    color: #F7E226;
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    width: 90vw;
    max-width: 1200px;
    position: relative;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    padding-top: 10px;
    z-index: 9998; /* Висок z-index за целия header */
}

/* Header content (title + paragraph) */
.header-content {
    flex: 1 1 auto;
    min-width: 0;
    overflow: visible;
}

/* ULTRA SPECIFIC - will override EVERYTHING */
header.app-main-header .app-logo-title {
    margin: 0 !important;
    line-height: 1.2 !important;
    font-size: 2.2em !important;  /* Намален размер */
    margin-bottom: 0em !important;
    display: inline-block !important;
    padding: 8px 20px !important;
    transition: all 0.3s ease !important;
    font-family: 'Nunito', sans-serif !important;
    font-weight: bold !important;
    letter-spacing: 0.05em !important;
    color: #F7E226 !important;
}

/* Fallback for generic .title inside header */
header .title {
    margin: 0 !important;
    line-height: 1.2 !important;
    font-size: 3em !important;
    margin-bottom: 0em !important;
    display: inline-block !important;
    padding: 8px 20px !important;
    transition: all 0.3s ease !important;
    font-family: 'Nunito', sans-serif !important;
    font-weight: bold !important;
    letter-spacing: 0.05em !important;
}

.title-link {
    text-decoration: none;
    transition: color 0.3s ease;
    color: #F7E226;
    position: relative;
    z-index: 10000; /* Above .header-right (9999) so logo text is never covered */
}

.title-link:hover,
.title-link:focus {
    color: #F7E226;
    text-decoration: none;
}

header .header-paragraph {
    color: #40403e;
    margin-top: 0;
}

/* User dropdown */
.dropdown {
    color: #40403e;
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
    letter-spacing: 0.05em;
    position: relative;
    display: inline-block;
    text-align: right;
    margin-left: auto;
    flex-shrink: 0;
    z-index: 9999; /* Много висок z-index за да е винаги отгоре */
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #FFFFFF;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 999999 !important; /* Максимален z-index с !important */
    border-radius: 5px;
    overflow: visible !important; /* Позволява съдържанието да излиза извън границите */
    white-space: nowrap;
    transform-origin: top right;
}

.dropdown-content a {
    color: #40403e;
    text-decoration: none;
    display: block;
    padding: 12px 16px;
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
    letter-spacing: 0.05em;
    font-size: 1em;
    text-align: center;
}

.dropdown-content a:hover {
    background-color: #F7E226;
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
    display: block;
}

/* User button */
button.dropbtn {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: transparent;
    border: none;
    padding: 0;
    margin-right: 2.6em;
    color: #40403e;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

button.dropbtn i.fas.fa-user {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #F7E226;
    color: white;
    border-radius: 50%;
}

button.dropbtn:hover {
    color: #E6C200;
    background-color: transparent;
}

/* User initial circle */
.user-initial-circle {
    width: 36px;
    height: 36px;
    background-color: #F7E226;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s;
    box-sizing: border-box;
}

.user-initial-circle.placeholder {
    background-color: #F7E226;
    color: transparent;
}

.user-initial-circle:hover,
.dropdown:hover .user-initial-circle {
    background-color: #F7E226;
}

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    z-index: 9999; /* Висок z-index за контейнера с dropdown-ите */
    position: relative; /* Необходимо за z-index да работи */
}

/* Language dropdown container */
.lang-dropdown {
    position: relative;
    display: inline-block;
    z-index: 9999; /* Висок z-index за езиковия dropdown */
}

/* Language button */
.lang-dropbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
    font-size: 14px;
    color: #40403e;
    min-width: 50px;
    letter-spacing: 0.05em;
}

.lang-dropbtn:hover {
    background: rgba(247, 226, 38, 0.2);
    border-color: #F7E226;
}

.lang-code {
    font-weight: bold;
    letter-spacing: 0.05em;
}

/* Language dropdown content */
.lang-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #FFFFFF;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 999999 !important; /* Максимален z-index с !important */
    border-radius: 8px;
    overflow: visible !important; /* Позволява съдържанието да излиза извън границите */
    transform-origin: top right;
    padding-top: 4px;
}

/* Show dropdown on hover */
.lang-dropdown:hover .lang-dropdown-content,
.lang-dropdown:focus-within .lang-dropdown-content {
    display: block;
}

/* Show dropdown on click for language dropdown */
.lang-dropdown-content.show {
    display: block !important;
}

/* Show dropdown content when parent has show class */
.dropdown.show .dropdown-content {
    display: block !important;
}

/* Допълнителни стилове за гарантирано показване на dropdown-ите */
.dropdown-content.show,
.dropdown-content:hover,
.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content,
.lang-dropdown-content.show,
.lang-dropdown-content:hover,
.lang-dropdown:hover .lang-dropdown-content,
.lang-dropdown:focus-within .lang-dropdown-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Гарантиране че родителските елементи не скриват dropdown-ите */
.dropdown,
.lang-dropdown {
    overflow: visible !important;
}

/* Гарантиране че header не скрива dropdown-ите */
header {
    overflow: visible !important;
}

/* Language option items */
.lang-option {
    display: block;
    padding: 10px 16px;
    color: #40403e;
    text-decoration: none;
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Nunito', sans-serif;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
}

.lang-option:hover {
    background-color: rgba(247, 226, 38, 0.15);
}

.lang-option.active {
    background-color: #F7E226;
    font-weight: bold;
}

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

/* Desktop and tablets */
@media (min-width: 768px) {
    header {
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }

    header .header-content {
        text-align: left;
    }

    header .dropdown {
        align-self: center;
        margin-left: auto;
    }
}

/* Medium screens (tablets) */
@media (min-width: 576px) and (max-width: 768px) {
    header {
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 12px;
        padding-left: 3vw;
        padding-right: 3vw;
    }

    header .header-content {
        flex: 1 1 auto;
        min-width: 0;
        text-align: left !important;
        width: auto !important;
        overflow: visible;
    }

    header .title {
        font-size: 2em !important;
        white-space: nowrap;
    }

    header .header-paragraph {
        font-size: 0.9em;
    }

    .dropdown {
        width: auto !important;
        margin-left: auto !important;
        margin-top: 0 !important;
        flex-shrink: 0;
    }

    button.dropbtn {
        margin-right: 0.5em;
    }

    .dropdown-content {
        right: 0;
        left: auto;
        min-width: 180px;
    }
}

/* Small screens (mobile) */
@media (max-width: 576px) {
    header {
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 10px;
        padding-left: 3vw;
        padding-right: 3vw;
        width: 94vw !important;
        overflow: visible !important; /* Важно за dropdown-ите */
    }

    header .header-content {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center !important;
        width: auto !important;
        overflow: visible;
        margin-left: 20px;
    }

    .header-right {
        gap: 8px;
        overflow: visible !important; /* Важно за dropdown-ите */
    }

    /* Language dropdown adjustments for mobile - LARGER for touch */
    .lang-dropbtn {
        min-width: 60px;
        padding: 10px 14px;
        font-size: 15px;
        min-height: 44px; /* Minimum touch target */
    }

    .lang-dropdown-content {
        min-width: 180px;
        right: 0 !important;
        top: 100% !important;
    }

    .lang-option {
        padding: 14px 18px;
        font-size: 16px;
        min-height: 48px;
    }

    header .title {
        font-size: 1.7em !important;
        white-space: nowrap;
        padding: 8px 16px !important;
    }

    /* Specific selector for app-logo-title */
    header.app-main-header .app-logo-title {
        font-size: 1.7em !important;
        white-space: nowrap;
        padding: 8px 16px !important;
    }

    header .header-paragraph {
        font-size: 0.85em;
        display: none;
    }

    .dropdown {
        width: auto !important;
        margin-left: auto !important;
        margin-top: 0 !important;
        flex-shrink: 0;
        margin-right: 12px;
        overflow: visible !important; /* Важно за dropdown-ите */
    }

    button.dropbtn {
        margin-right: 0;
    }

    /* User dropdown - LARGER for touch */
    .dropdown-content {
        right: 0 !important;
        top: 100% !important;
        min-width: 200px;
        max-width: 85vw;
    }

    .dropdown-content a {
        font-size: 16px;
        padding: 14px 18px;
        min-height: 48px;
    }

    button.dropbtn,
    .user-initial-circle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    button.dropbtn i.fas.fa-user,
    .user-initial-circle {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    header {
        width: 98vw !important;
        gap: 8px;
        padding-left: 1vw;
        padding-right: 1vw;
    }

    header .header-content {
        margin-left: 15px;
    }

    header .title {
        font-size: 1.5em !important;
        padding: 6px 12px !important;
    }

    header.app-main-header .app-logo-title {
        font-size: 1.5em !important;
        padding: 6px 12px !important;
    }

    .dropdown {
        margin-right: 8px;
    }

    /* Keep touch-friendly sizes on very small screens */
    .dropdown-content {
        min-width: 180px;
        max-width: 85vw;
    }

    .dropdown-content a {
        font-size: 15px;
        padding: 12px 16px;
        min-height: 44px;
    }

    .lang-dropbtn {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 44px;
    }

    .lang-option {
        padding: 12px 16px;
        font-size: 15px;
        min-height: 44px;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    header {
        width: 100vw !important;
        gap: 6px;
    }

    header .header-content {
        margin-left: 10px;
    }

    header .title {
        font-size: 1.3em !important;
        padding: 4px 10px !important;
    }

    header.app-main-header .app-logo-title {
        font-size: 1.3em !important;
        padding: 4px 10px !important;
    }

    .dropdown {
        margin-right: 6px;
    }

    /* Keep minimum touch targets even on smallest screens */
    button.dropbtn,
    .user-initial-circle {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    button.dropbtn i.fas.fa-user,
    .user-initial-circle {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .dropdown-content {
        min-width: 160px;
        max-width: 80vw;
    }

    .dropdown-content a {
        font-size: 14px;
        padding: 11px 14px;
        min-height: 40px;
    }

    .lang-dropbtn {
        padding: 6px 10px;
        font-size: 13px;
        min-height: 40px;
        min-width: 50px;
    }

    .lang-option {
        padding: 11px 14px;
        font-size: 14px;
        min-height: 40px;
    }
}

