/* ==========================================================================
   顺锐紧固件 · 前端交互组件
   询价弹窗 / 登录注册 / CSRF / API 封装
   --------------------------------------------------------------------------
   引入方式（放在 </body> 前）：
     <link rel="stylesheet" href="css/components.css">
     <script src="js/app.js" defer></script>
   ========================================================================== */

/* ==========================================================================
   1. 弹窗基础
   ========================================================================== */
.sr-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.sr-modal.is-open {
    display: flex;
}

.sr-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}

.sr-modal__panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.28);
    animation: sr-modal-in 0.2s ease-out;
}

.sr-modal__panel--wide {
    max-width: 640px;
}

@keyframes sr-modal-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sr-modal__panel {
        animation: none;
    }
}

.sr-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.875rem;
    border-bottom: 1px solid #e5e7eb;
}

.sr-modal__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    line-height: 1.4;
}

.sr-modal__subtitle {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0.25rem 0 0;
}

.sr-modal__close {
    flex: none;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.sr-modal__close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.sr-modal__body {
    padding: 1.25rem 1.5rem;
}

.sr-modal__foot {
    display: flex;
    gap: 0.625rem;
    justify-content: flex-end;
    padding: 0 1.5rem 1.25rem;
}

/* ==========================================================================
   2. 表单
   ========================================================================== */
.sr-form {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.sr-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sr-field__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #334155;
}

.sr-field__label .sr-req {
    color: #dc2626;
    margin-left: 2px;
}

.sr-field__hint {
    font-size: 0.75rem;
    color: #94a3b8;
}

.sr-input,
.sr-textarea,
.sr-select {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sr-input:focus,
.sr-textarea:focus,
.sr-select:focus {
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.sr-input[aria-invalid="true"],
.sr-textarea[aria-invalid="true"] {
    border-color: #dc2626;
}

.sr-textarea {
    min-height: 96px;
    resize: vertical;
}

.sr-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
}

@media (max-width: 480px) {
    .sr-form__row {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   3. 按钮
   ========================================================================== */
.sr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 42px;
    padding: 0 1.125rem;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.sr-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.sr-btn--primary {
    background: #1e3a8a;
    color: #fff;
}

.sr-btn--primary:hover:not(:disabled) {
    background: #1e40af;
}

.sr-btn--ghost {
    background: #fff;
    border-color: #cbd5e1;
    color: #334155;
}

.sr-btn--ghost:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #94a3b8;
}

.sr-btn--block {
    width: 100%;
}

/* ==========================================================================
   4. 提示条
   ========================================================================== */
.sr-alert {
    padding: 0.6875rem 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    border-radius: 8px;
    border: 1px solid transparent;
    margin-bottom: 0.875rem;
    display: none;
}

.sr-alert.is-visible {
    display: block;
}

.sr-alert--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.sr-alert--ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.sr-alert--info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* ==========================================================================
   5. 加载态
   ========================================================================== */
.sr-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sr-spin 0.6s linear infinite;
}

.sr-btn--ghost .sr-spinner {
    border-color: rgba(51, 65, 85, 0.25);
    border-top-color: #334155;
}

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

/* ==========================================================================
   6. 登录态提示条（页面顶部）
   ========================================================================== */
.sr-userbar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 0.8125rem;
}

.sr-userbar.is-visible {
    display: flex;
}

.sr-userbar__name {
    font-weight: 500;
}

.sr-userbar__spacer {
    flex: 1;
}

/* ==========================================================================
   7. 移动端菜单（首页当前缺失）
   ========================================================================== */
.sr-mobilenav {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem 1rem;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.sr-mobilenav.is-open {
    display: flex;
}

.sr-mobilenav a {
    padding: 0.5rem 0.25rem;
    color: #374151;
    font-size: 0.9375rem;
    text-decoration: none;
}

.sr-mobilenav a:hover {
    color: #1e3a8a;
}

/* ==========================================================================
   8. 成功页
   ========================================================================== */
.sr-success {
    text-align: center;
    padding: 0.5rem 0;
}

.sr-success__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #dcfce7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sr-success__icon svg {
    width: 26px;
    height: 26px;
    stroke: #16a34a;
    stroke-width: 2.5;
    fill: none;
}

.sr-success__title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 0.375rem;
}

.sr-success__text {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
    line-height: 1.7;
}
