/* ========================================
   ВХОД / ПРОФИЛ (js/auth.js)
   ========================================
   Зарежда се след style.css на страниците с
   основна навигация. Елементите се създават от
   auth.js само когато js/auth-config.js е попълнен.
   - .auth-control: „Вход“ / „Профил“ в .header-tools
   - .auth-menu-item: същото в мобилното меню (≤560px)
   - .auth-profile-menu: падащо меню на профила
   - .auth-dialog: вход
======================================== */

/* Страници без езиков превключвател (auth.js създава
   .header-tools) - същото като в lang-switch.css */
.header-inner > .main-nav {
    margin-left: auto;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------- Бутон в навигацията ---------- */

.auth-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--navy);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.auth-control-wrap {
    position: relative;
    display: flex;
}

.auth-control-signin,
.auth-control-profile {
    padding: 0 16px;
    border-radius: 999px;
}

.auth-control-signin:hover,
.auth-control-signin:focus-visible,
.auth-control-profile:hover,
.auth-control-profile:focus-visible,
.auth-control-profile[aria-expanded="true"] {
    border-color: var(--green);
    color: var(--green);
}

.auth-control:focus-visible,
.auth-menu-item:focus-visible,
.auth-profile-link:focus-visible,
.auth-dialog button:focus-visible,
.auth-input:focus-visible {
    outline: 3px solid rgba(15, 143, 114, 0.35);
    outline-offset: 2px;
}

/* В мобилното меню - само на тесен екран */
.auth-menu-item {
    display: none;
}

@media (max-width: 980px) {
    .auth-control {
        height: 44px;
    }

    .auth-control-signin,
    .auth-control-profile {
        border-radius: 10px;
    }
}

/* Скритият елемент не трябва да оставя разделител
   под последната връзка в отвореното меню */
@media (min-width: 561px) and (max-width: 980px) {
    .main-nav a:has(+ .auth-menu-item) {
        border-bottom: none;
    }
}

@media (max-width: 560px) {
    /* Обвивката не заема място; менюто на профила
       се позиционира спрямо .site-header */
    .auth-control-wrap {
        display: contents;
    }

    .auth-control-wrap > .auth-control {
        display: none;
    }

    .main-nav .auth-menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 12px 0;
        border: none;
        background: none;
        color: var(--green);
        font-family: inherit;
        font-size: 15px;
        font-weight: 700;
        text-align: left;
        cursor: pointer;
    }
}

/* ---------- Аватар ---------- */

.auth-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--green);
    color: var(--white);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.auth-avatar-small {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

/* ---------- Диалог ---------- */

.auth-dialog {
    width: min(420px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    margin: auto;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    box-shadow: var(--shadow);
    overflow: auto;
}

.auth-dialog::backdrop {
    background: rgba(11, 46, 79, 0.45);
}

.auth-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 32px 28px 28px;
}

.auth-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.auth-close:hover {
    background: var(--light-blue);
    color: var(--navy);
}

.auth-title {
    padding-right: 32px;
    color: var(--navy);
    font-size: 22px;
    line-height: 1.25;
}

.auth-intro {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.auth-error {
    padding: 10px 14px;
    border-radius: 12px;
    background: #fdecec;
    color: #9b1c1c;
    font-size: 13px;
    line-height: 1.45;
}

.auth-error[hidden] {
    display: none;
}

.auth-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.auth-button:disabled {
    cursor: progress;
    opacity: 0.7;
}

.auth-button-google {
    background: var(--white);
    border-color: var(--border);
    color: var(--navy);
}

.auth-button-google:hover:not(:disabled) {
    border-color: var(--green);
}

.auth-button-primary {
    background: var(--green);
    color: var(--white);
}

.auth-button-primary:hover:not(:disabled) {
    background: #0b7d64;
}

.auth-google-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-notice {
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--light-green);
    color: var(--navy);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

.auth-notice[hidden] {
    display: none;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.auth-label {
    color: var(--navy);
    font-size: 13px;
    font-weight: 700;
}

.auth-input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--white);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
}

.auth-input:focus {
    border-color: var(--green);
}

.auth-input[aria-invalid="true"] {
    border-color: #c53030;
}

.auth-form .auth-button-primary {
    margin-top: 4px;
}

.auth-switch {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.auth-link-button {
    padding: 0;
    border: none;
    background: none;
    color: var(--green);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Меню на профила ---------- */

.auth-profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 110;
    display: flex;
    flex-direction: column;
    width: max-content;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 32px));
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
}

.auth-profile-menu[hidden] {
    display: none;
}

.auth-profile-info {
    padding: 8px 10px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.auth-profile-link {
    display: block;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--navy);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.auth-profile-link:hover:not(:disabled) {
    background: rgba(15, 143, 114, 0.08);
    color: var(--green);
}

.auth-profile-link:disabled {
    cursor: progress;
    opacity: 0.7;
}

@media (max-width: 560px) {
    .auth-profile-menu {
        top: 100%;
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
        margin-top: 8px;
    }
}

.auth-account-name {
    color: var(--navy);
    font-size: 16px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.auth-account-email {
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}
