/* ============================================================
   Løbeklubben Auth — Standalone modal + nav item styles
   All classes are prefixed with .lb-auth- to avoid conflicts.
   Respects prefers-color-scheme for dark/light mode.
   ============================================================ */

:root {
    --lb-primary:        #4a7c59;
    --lb-primary-hover:  #3a6147;
    --lb-bg:             #ffffff;
    --lb-surface:        #f7f7f7;
    --lb-text:           #1a1a1a;
    --lb-text-muted:     #666666;
    --lb-border:         #e2e2e2;
    --lb-input-bg:       #f5f5f5;
    --lb-overlay:        rgba(0, 0, 0, 0.45);
    --lb-radius:         14px;
    --lb-radius-sm:      8px;
    --lb-shadow:         0 12px 40px rgba(0, 0, 0, 0.18);
    --lb-error-bg:       rgba(220, 38, 38, 0.08);
    --lb-error-color:    #dc2626;
    --lb-toast-success:  #166534;
    --lb-toast-info:     #1e40af;
    --lb-transition:     0.18s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --lb-bg:         #1c1c1e;
        --lb-surface:    #2c2c2e;
        --lb-text:       #f0f0f0;
        --lb-text-muted: #a0a0a0;
        --lb-border:     #3a3a3c;
        --lb-input-bg:   #2c2c2e;
        --lb-overlay:    rgba(0, 0, 0, 0.65);
    }
}

/* ---- SVG icon ---- */

.lb-auth-icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: -0.15em;
    margin-right: 0.35em;
    flex-shrink: 0;
}

/* ============================================================
   MODAL BACKDROP
   ============================================================ */

#lbAuthModal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--lb-overlay);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

#lbAuthModal.lb-visible {
    display: flex;
    animation: lbFadeIn var(--lb-transition) both;
}

@keyframes lbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   MODAL BOX
   ============================================================ */

.lb-auth-modal {
    background: var(--lb-bg);
    color: var(--lb-text);
    border-radius: var(--lb-radius);
    box-shadow: var(--lb-shadow);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: lbSlideUp 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes lbSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ---- Header ---- */

.lb-auth-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--lb-border);
}

.lb-auth-modal-title {
    display: flex;
    align-items: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--lb-text);
}

.lb-auth-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--lb-text-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    transition: color var(--lb-transition), background var(--lb-transition);
}

.lb-auth-close:hover {
    color: var(--lb-text);
    background: var(--lb-surface);
}

/* ---- Body ---- */

.lb-auth-modal-body {
    padding: 1.5rem;
}

/* ---- Tabs ---- */

.lb-auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--lb-border);
    margin-bottom: 1.25rem;
}

.lb-auth-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--lb-text-muted);
    cursor: pointer;
    transition: color var(--lb-transition), border-color var(--lb-transition);
    font-family: inherit;
}

.lb-auth-tab:hover {
    color: var(--lb-text);
}

.lb-auth-tab.lb-active {
    color: var(--lb-primary);
    border-bottom-color: var(--lb-primary);
}

/* ---- Form fields ---- */

.lb-auth-field {
    margin-bottom: 1rem;
}

.lb-auth-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--lb-text-muted);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.lb-auth-field input {
    display: block;
    width: 100%;
    padding: 0.65rem 0.875rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--lb-text);
    background: var(--lb-input-bg);
    border: 1px solid var(--lb-border);
    border-radius: var(--lb-radius-sm);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--lb-transition), box-shadow var(--lb-transition);
}

.lb-auth-field input:focus {
    border-color: var(--lb-primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.lb-auth-field input::placeholder {
    color: var(--lb-text-muted);
    opacity: 0.7;
}

/* ---- Error ---- */

.lb-auth-error {
    display: none;
    font-size: 0.85rem;
    color: var(--lb-error-color);
    background: var(--lb-error-bg);
    border-radius: var(--lb-radius-sm);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.875rem;
}

/* ---- Submit button ---- */

.lb-auth-submit {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    color: #ffffff;
    background: var(--lb-primary);
    border: none;
    border-radius: var(--lb-radius-sm);
    cursor: pointer;
    transition: background var(--lb-transition), opacity var(--lb-transition);
    margin-top: 0.25rem;
    letter-spacing: 0.01em;
}

.lb-auth-submit:hover {
    background: var(--lb-primary-hover);
}

.lb-auth-submit:disabled {
    opacity: 0.55;
    cursor: default;
}

/* ---- Switch link ---- */

.lb-auth-switch {
    font-size: 0.85rem;
    text-align: center;
    margin: 1rem 0 0;
    color: var(--lb-text-muted);
}

.lb-auth-switch a {
    color: var(--lb-primary);
    text-decoration: underline;
    cursor: pointer;
}

.lb-auth-switch a:hover {
    text-decoration: none;
}

/* ============================================================
   NAV MENU ITEM
   ============================================================ */

.lb-auth-nav-item {
    list-style: none;
    display: flex;
    align-items: center;
    position: relative; /* anchor for the dropdown */
}

/* ---- Login link (logged-out state) ---- */

.lb-auth-login-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    cursor: pointer;
    transition: opacity var(--lb-transition);
}

.lb-auth-login-link:hover { opacity: 0.75; }

/* ---- Username button (logged-in state) ---- */

.lb-auth-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    padding: 0.25rem 0.5rem !important;
    margin: 0 !important;
    border-radius: 6px;
    transition: background var(--lb-transition);
    line-height: 1;
}

.lb-auth-user-btn:hover,
.lb-auth-user-btn--open {
    background: rgba(0, 0, 0, 0.07);
}

.lb-auth-caret {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform var(--lb-transition);
}

.lb-auth-user-btn--open .lb-auth-caret {
    transform: rotate(180deg);
}

/* ---- Dropdown ---- */

.lb-auth-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 99998;
    padding: 4px;
    animation: lbDropIn 0.15s ease both;
}

@keyframes lbDropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lb-auth-dropdown-item {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 0.55rem 0.75rem !important;
    margin: 0 !important;
    font-size: 0.9rem;
    color: #1d1d1f;
    text-decoration: none;
    border-radius: 7px;
    cursor: pointer;
    transition: background var(--lb-transition);
    white-space: nowrap;
    border: none;
    background: none;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.lb-auth-dropdown-item:hover {
    background: #f2f2f7;
    color: #1d1d1f;
    text-decoration: none;
}

.lb-auth-dropdown-item.lb-auth-logout-link {
    color: #dc2626;
}

.lb-auth-dropdown-item.lb-auth-logout-link:hover {
    background: rgba(220, 38, 38, 0.08);
}

.lb-auth-dropdown-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.lb-auth-dropdown-divider {
    height: 1px;
    background: #e5e5ea;
    margin: 4px 0;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */

.lb-auth-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    z-index: 1000000;
    padding: 0.65rem 1.25rem;
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-family: inherit;
}

.lb-auth-toast.lb-auth-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.lb-auth-toast-success { background: var(--lb-toast-success); }
.lb-auth-toast-info    { background: var(--lb-toast-info); }
.lb-auth-toast-error   { background: var(--lb-error-color); }
