/**
 * Auth modali + header dugmad — frontend stil za Login/Register feature.
 *
 * Dizajn se oslanja na brand gold paletu (--gold #C8963E) iz main.css.
 * Modal patern je industry standard:
 *   - fixed overlay sa blur background-om (backdrop-filter)
 *   - centriran content sa fade-in animacijom + soft slide
 *   - max-width 440px (mobile-first responsive)
 *   - ESC keypress + click-outside-to-close (handler u auth.js)
 *
 * @author  Web Center
 * @version 3.6.1
 */

/* ========== Header dugmad (Login/Register) ========== */

.auth-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 12px;
}

/* Global span override — main.css (linije 367-391) primjenjuje na SVE
   <span> elemente:
     - `color: var(--gold)` (gold tekst)
     - `letter-spacing: 3px`, `text-transform: uppercase`, `font-weight: 600`
     - `span::before` zlatna crtica 40×2px
   Ovi stilovi lome submit dugmad u modal-u ("Prijavi se" postaje gold
   tekst na gold pozadini = nečitljivo). Resetujemo span stilove unutar
   svih auth dugmadi/dropdown-a, ali NAMJERNO NE diramo `.auth-field > span`
   (labele "EMAIL"/"LOZINKA") jer su tu gold tekst + crtica dio brand
   dekoracije koja izgleda lijepo.
   Isti pattern vidi u main.css:11129 (`.contact-form-submit span`). */
.auth-header-actions span,
.auth-submit-btn span,
.auth-success-state span,
.auth-user-menu span,
.auth-verify-btn span {
    color: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    padding-left: 0 !important;
    gap: 0 !important;
    display: inline-block !important;
}

/* HTML `hidden` atribut radi preko `display: none`. Naš reset iznad
   forsira `display: inline-block !important` na SVAKI span u auth scope-u,
   što override-uje `hidden` pa spinner (koji je `<span hidden>`) ostaje
   vidljiv od početka — izgleda kao da dugme učitava prije klika.
   Explicit override da [hidden] ima viši prioritet. */
.auth-header-actions span[hidden],
.auth-submit-btn span[hidden],
.auth-success-state span[hidden],
.auth-user-menu span[hidden],
.auth-verify-btn span[hidden] {
    display: none !important;
}

.auth-header-actions span::before,
.auth-submit-btn span::before,
.auth-success-state span::before,
.auth-user-menu span::before,
.auth-verify-btn span::before {
    content: none !important;
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
}

.auth-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.25px;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.25s cubic-bezier(0.25,0.46,0.45,0.94),
                border-color 0.25s, color 0.25s, transform 0.2s, box-shadow 0.25s;
    background: transparent;
    color: inherit;
    font-family: inherit;
    line-height: 1.2;
}

/* Header ima 2 stanja (iz main.css):
     1. Default (na vrhu stranice) — tamna/providna pozadina, svijetli tekst
     2. `.small-header` (scrolled) — bijela pozadina, crni tekst
   Auth "Prijava" dugme mora ostati čitljivo u oba. Rješenje: default
   bijeli tekst + gold border, a kad header ima `.small-header` klasu,
   overrajduj na tamni tekst. */
.auth-header-btn--login {
    color: #fff;
    border-color: var(--gold, #C8963E);
    background: transparent;
}

.auth-header-btn--login:hover {
    background: var(--gold, #C8963E);
    color: #fff;
    border-color: var(--gold, #C8963E);
}

header.small-header .auth-header-btn--login {
    color: var(--dark, #1A1A1A);
}

header.small-header .auth-header-btn--login:hover {
    color: #fff;
}

.auth-header-btn--register {
    background: var(--gold-gradient, linear-gradient(135deg, #D4A843 0%, #C8963E 50%, #A07830 100%));
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-gold, 0 4px 20px rgba(200,150,62,0.15));
}

.auth-header-btn--register:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(200,150,62,0.25);
    color: #fff;
}

/* `.btn` klasa iz main.css (linija 221) ima ::after pseudo-element sa
   arrow ikonom — isključujemo ga u auth scope-u da ne pokvari layout
   header dugmadi. Naša dugmad nemaju .btn ali zaštita za svaki slučaj. */
.auth-header-btn::after,
.auth-submit-btn::after,
.auth-verify-btn::after {
    content: none !important;
    display: none !important;
}

/* User dropdown (kad je ulogovan) */

.auth-user-menu {
    position: relative;
    display: inline-block;
}

.auth-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: inherit;
    line-height: 1.2;
}

.auth-user-trigger:hover {
    background: rgba(0, 0, 0, 0.04);
}

.auth-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gold-gradient, linear-gradient(135deg, #D4A843 0%, #C8963E 50%, #A07830 100%));
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(200,150,62,0.2);
}

.auth-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
}

.auth-user-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.auth-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    color: #1a1a1a;
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.auth-dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.auth-dropdown-item--logout {
    color: #c92a2a;
}

.auth-dropdown-item--logout:hover {
    background: rgba(201, 42, 42, 0.08);
}

.auth-dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 4px 0;
}

/* ========== Modal Overlay ========== */

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.18s ease-out;
}

.auth-modal-overlay.is-open {
    opacity: 1;
}

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

/* ========== Modal Container ========== */

.auth-modal {
    background: var(--white, #fff);
    border-radius: var(--radius-md, 20px);
    padding: 40px 36px 32px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg, 0 8px 40px rgba(0, 0, 0, 0.12));
    position: relative;
    transform: translateY(12px) scale(0.97);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.25s ease-out;
    box-sizing: border-box;
}

.auth-modal-overlay.is-open .auth-modal:not([hidden]) {
    transform: translateY(0) scale(1);
    opacity: 1;
}

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

.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.auth-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #1a1a1a;
}

.auth-modal-title {
    font-size: 26px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--dark, #1A1A1A);
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.auth-modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #555);
    margin: 0 0 28px 0;
    line-height: 1.5;
}

/* ========== Form ========== */

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

.auth-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.auth-field > span {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.auth-field > span small {
    font-weight: 400;
    color: #888;
    font-size: 12px;
}

.auth-field input {
    padding: 12px 16px;
    border: 1px solid var(--bg-grey, #EDEAE4);
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-warm, #FAF9F6);
    color: var(--dark, #1A1A1A);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
    width: 100%;
}

.auth-field input:focus {
    outline: none;
    background: #fff;
    border-color: var(--gold, #C8963E);
    box-shadow: 0 0 0 3px rgba(200, 150, 62, 0.12);
}

.auth-field input::placeholder {
    color: #adb5bd;
}

/* Honeypot — vizuelno potpuno skriven, ali fokusabilan/popunjiv */
.auth-honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Error i success boxovi */

.auth-form-error,
.auth-form-success {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.auth-form-error {
    background: rgba(201, 42, 42, 0.08);
    color: #b91c1c;
    border: 1px solid rgba(201, 42, 42, 0.2);
}

.auth-form-success {
    background: rgba(34, 139, 34, 0.08);
    color: #1e7e1e;
    border: 1px solid rgba(34, 139, 34, 0.2);
}

/* Submit button */

.auth-submit-btn {
    padding: 14px 24px;
    background: var(--gold-gradient, linear-gradient(135deg, #D4A843 0%, #C8963E 50%, #A07830 100%));
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: box-shadow 0.25s cubic-bezier(0.25,0.46,0.45,0.94),
                transform 0.2s, opacity 0.15s;
    box-shadow: var(--shadow-gold, 0 4px 20px rgba(200,150,62,0.15));
    margin-top: 8px;
    line-height: 1.2;
}

.auth-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(200,150,62,0.28);
}

.auth-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Spinner */

.auth-btn-spinner,
.auth-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: auth-spin 0.6s linear infinite;
}

.auth-spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
    color: var(--gold, #C8963E);
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

/* Switch link (alt action ispod forme) */

.auth-modal-switch {
    text-align: center;
    font-size: 13px;
    color: #666;
    margin-top: 8px;
}

.auth-modal-switch a {
    color: var(--gold-dark, #A07830);
    text-decoration: none;
    font-weight: 600;
}

.auth-modal-switch a:hover {
    color: var(--gold, #C8963E);
    text-decoration: underline;
}

/* ========== Verify-email landing ========== */

.auth-verify-section {
    padding: 80px 20px;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-verify-section .max-width {
    width: 100%;
    max-width: 480px;
}

.auth-verify-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.auth-verify-card h1 {
    font-size: 26px;
    font-weight: 600;
    margin: 16px 0 12px 0;
    color: #1a1a1a;
}

.auth-verify-card p {
    color: #666;
    line-height: 1.6;
    margin: 0 0 24px 0;
    font-size: 15px;
}

.auth-verify-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 8px;
}

.auth-verify-card--loading .auth-verify-icon {
    background: rgba(200, 150, 62, 0.1);
    color: var(--gold, #C8963E);
}

.auth-verify-card--success .auth-verify-icon {
    background: rgba(34, 139, 34, 0.1);
    color: #1e7e1e;
}

.auth-verify-card--error .auth-verify-icon {
    background: rgba(201, 42, 42, 0.08);
    color: #b91c1c;
}

.auth-verify-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    background: var(--gold-gradient, linear-gradient(135deg, #D4A843 0%, #C8963E 50%, #A07830 100%));
    color: #fff;
    border-radius: 30px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-decoration: none;
    font-size: 15px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.25s;
    box-shadow: var(--shadow-gold, 0 4px 20px rgba(200,150,62,0.15));
}

.auth-verify-btn:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(200,150,62,0.28);
}

/* ========== Success modal (registracija potvrda) ========== */

/* Prikazuje se nakon uspješne registracije UMJESTO alert(). Zamjenjuje
   sadržaj register modala i traži od usera da provjeri mail. Dugme
   "Razumijem" zatvara modal. Ikonu vadimo iz svg-a u auth.js. */

.auth-success-state {
    text-align: center;
    padding: 8px 0;
}

.auth-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(34,139,34,0.1), rgba(30,126,30,0.06));
    color: #1e7e1e;
    margin-bottom: 20px;
    animation: auth-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes auth-pop {
    0%   { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.auth-success-state h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--dark, #1A1A1A);
    margin: 0 0 10px 0;
    letter-spacing: -0.2px;
}

.auth-success-state p {
    color: var(--text-secondary, #555);
    font-size: 14.5px;
    margin: 0 0 8px 0;
    line-height: 1.6;
}

.auth-success-state .auth-success-email {
    display: inline-block;
    background: var(--bg-light, #F5F3EF);
    color: var(--gold-dark, #A07830);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13.5px;
    margin: 6px 0 18px;
    font-family: 'SF Mono', ui-monospace, Menlo, monospace;
}

.auth-success-state .auth-success-hint {
    font-size: 13px;
    color: #888;
    margin-top: 18px;
}

.auth-success-state .auth-success-hint a {
    color: var(--gold-dark, #A07830);
    font-weight: 600;
    text-decoration: none;
}

.auth-success-state .auth-success-hint a:hover {
    text-decoration: underline;
}

.auth-success-state .auth-submit-btn {
    margin-top: 24px;
    min-width: 180px;
}

/* ========== Mobile ========== */

@media (max-width: 480px) {
    .auth-modal {
        padding: 24px 20px;
    }

    .auth-modal-title {
        font-size: 20px;
    }

    .auth-form-row {
        grid-template-columns: 1fr;
    }

    .auth-header-actions {
        gap: 6px;
        margin-right: 8px;
    }

    .auth-header-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .auth-user-name {
        max-width: 80px;
    }
}
