/* ===== SPW Auth Modal ===== */

/* Overlay */
#authModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
#authModal.open { display: flex; }

.am-container {
    background: #12121a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 36px;
    animation: amSlideIn 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
@keyframes amSlideIn { from { opacity:0; transform:translateY(-16px); } to { opacity:1; transform:translateY(0); } }

.am-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.am-header h2 { color: #fff; font-size: 20px; margin: 0; }
.am-close {
    background: none; border: none; color: #9ca3af; font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 6px; line-height: 1;
    transition: color .2s, background .2s;
}
.am-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

.am-sub { color: #9ca3af; font-size: 14px; margin: -12px 0 20px; line-height: 1.6; }

/* Form grid */
.am-form { display: flex; flex-direction: column; gap: 12px; }
.am-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.am-col-full  { grid-column: 1 / -1; }
.am-col-1     { grid-column: 1; }
.am-col-2     { grid-column: 2; }
.am-col-mid   { grid-column: 1 / -1; }

@media (max-width: 480px) {
    .am-grid { grid-template-columns: 1fr; }
    .am-col-1, .am-col-2 { grid-column: 1; }
    .am-container { padding: 24px 20px; }
}

/* Inputs */
.am-form input:not([type="checkbox"]),
.am-form select {
    width: 100%;
    padding: 11px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 9px;
    color: #e0e0e6;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color .2s;
    -webkit-appearance: none;
}
.am-form input:focus,
.am-form select:focus { outline: none; border-color: #6366F1; }
.am-form input::placeholder { color: #6b7280; }
.am-form select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:32px; }
.am-form select option { background: #1a1a2e; }

/* Password field */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 72px; }
.pw-eye, .pw-gen {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: #6b7280;
    padding: 4px 6px; font-size: 14px; border-radius: 4px;
    transition: color .2s;
}
.pw-eye:hover, .pw-gen:hover { color: #e0e0e6; }
.pw-eye  { right: 36px; }
.pw-gen  { right: 6px; }
.pw-wrap:not(:has(.pw-gen)) .pw-eye { right: 6px; }

/* Password rules */
.pw-rules { margin: 0; padding: 10px 14px; background: rgba(255,255,255,0.03); border-radius: 8px; list-style: none; font-size: 12px; }
.pw-rules li { color: #6b7280; padding: 2px 0; transition: color .2s; }
.pw-rules li::before { content: '○  '; }
.pw-rules li.ok { color: #10B981; }
.pw-rules li.ok::before { content: '✓  '; }

/* Checkbox */
.am-check { display: flex; align-items: center; gap: 8px; color: #9ca3af; font-size: 13px; cursor: pointer; user-select: none; }
.am-check input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px; height: 16px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: background .15s, border-color .15s;
}
.am-check input[type="checkbox"]:checked {
    background: #6366F1;
    border-color: #6366F1;
}
.am-check input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px; top: 1px;
    width: 5px; height: 9px;
    border: 2px solid #fff;
    border-top: none; border-left: none;
    transform: rotate(45deg);
}
.am-check input[type="checkbox"]:focus-visible { outline: 2px solid #6366F1; outline-offset: 2px; }

/* Button */
.am-btn {
    width: 100%; padding: 13px; background: linear-gradient(135deg,#3B82F6,#8B5CF6);
    color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: opacity .2s; margin-top: 4px;
}
.am-btn:hover { opacity: 0.9; }
.am-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Error / OK */
.am-err { color: #DC2626; font-size: 13px; min-height: 18px; text-align: center; }
.am-ok  { color: #10B981; font-size: 13px; min-height: 18px; text-align: center; }

/* Links row */
.am-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 16px; }
.am-links button { background: none; border: none; color: #8B5CF6; font-size: 13px; cursor: pointer; padding: 2px 0; font-family: inherit; }
.am-links button:hover { color: #a78bfa; }

/* Success */
.am-success { text-align: center; padding: 12px 0; }
.am-success-icon { font-size: 44px; margin-bottom: 12px; }
.am-success p { color: #9ca3af; font-size: 14px; line-height: 1.7; margin: 4px 0; }

/* ── Nav auth button ── */
.auth-nav-btn {
    padding: 7px 18px;
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .2s;
}
.auth-nav-btn:hover { opacity: 0.85; }

/* ── User dropdown menu ── */
.user-menu {
    position: fixed;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px;
    min-width: 200px;
    z-index: 3000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: amSlideIn .15s ease;
}
.um-name { color: #fff; font-weight: 600; font-size: 14px; padding: 4px 8px; }
.um-id   { color: #6b7280; font-size: 12px; padding: 0 8px 8px; }
.um-divider { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 4px 0; }
.um-item {
    display: block; width: 100%; padding: 9px 12px; background: none; border: none;
    color: #d1d5db; font-size: 14px; cursor: pointer; border-radius: 8px;
    text-decoration: none; font-family: inherit; text-align: left; transition: background .15s;
}
.um-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.um-logout { color: #DC2626; }
.um-logout:hover { background: rgba(220,38,38,0.1); color: #DC2626; }

/* ── Field validation states ── */
.am-form input.field-err,
.am-form select.field-err {
    border-color: #DC2626;
    background: rgba(220,38,38,0.06);
}
.am-form input.field-ok,
.am-form select.field-ok {
    border-color: #10B981;
    background: rgba(16,185,129,0.06);
}

/* ── Logout overlay ── */
#logoutOverlay { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; }
.lo-backdrop { position: absolute; inset: 0; background: rgba(10,10,15,0.85); backdrop-filter: grayscale(80%) brightness(0.4); }
.lo-modal {
    position: relative; background: #12121a; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 48px 40px; text-align: center; animation: amSlideIn .25s ease;
}
.lo-icon { font-size: 32px; color: #8B5CF6; margin-bottom: 8px; }
.lo-modal h3 { color: #fff; font-size: 22px; margin: 0 0 8px; }
.lo-modal p  { color: #9ca3af; margin: 0 0 20px; }
.lo-timer { width: 48px; height: 48px; border-radius: 50%; background: rgba(99,102,241,0.15); border: 2px solid #6366F1; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: #8B5CF6; margin: 0 auto; }
