/* ========== 摩瑪建材 會員系統 v4.0 美化版 ========== */

/* === 變數設定 === */
:root {
    --mm-primary: #d4af37;
    --mm-primary-dark: #aa8a2e;
    --mm-bg-dark: #0f0f1a;
    --mm-bg-card: #1a1a2e;
    --mm-bg-input: rgba(0, 0, 0, 0.4);
    --mm-text: #ffffff;
    --mm-text-muted: rgba(255, 255, 255, 0.6);
    --mm-border: rgba(212, 175, 55, 0.2);
    --mm-success: #10b981;
    --mm-danger: #ef4444;
    --mm-radius: 16px;
    --mm-radius-sm: 10px;
    --mm-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
}

/* === Modal 背景 === */
.mm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.mm-modal.open {
    display: block;
}

.mm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: mmFadeIn 0.3s ease;
}

/* === Modal 容器 === */
.mm-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 400px;
    max-height: 90vh;
    background: var(--mm-bg-card);
    border-radius: var(--mm-radius);
    box-shadow: var(--mm-shadow);
    border: 1px solid var(--mm-border);
    overflow: hidden;
    animation: mmSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* === 關閉按鈕 === */
.mm-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: var(--mm-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.25s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.mm-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--mm-danger);
    transform: rotate(90deg);
}

/* === View 通用 === */
.mm-view {
    padding: 1.75rem;
    overflow-y: auto;
    max-height: 85vh;
}

/* === 登入頁面 Header === */
.mm-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 1rem;
}

.mm-logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--mm-primary);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.mm-subtitle {
    font-size: 0.95rem;
    color: var(--mm-text-muted);
    letter-spacing: 1px;
}

/* === 登入內容 === */
.mm-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* === 輸入框 === */
.mm-input-box {
    position: relative;
}

.mm-input-box .mm-input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    pointer-events: none;
}

.mm-input-box #phoneInput {
    padding-left: 3rem;
}

#phoneInput,
.mm-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid rgba(212, 175, 55, 0.25);
    border-radius: var(--mm-radius-sm);
    background: var(--mm-bg-input);
    color: var(--mm-text);
    font-size: 1.1rem;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#phoneInput {
    text-align: center;
    font-size: 1.25rem;
    letter-spacing: 3px;
    font-weight: 500;
}

#phoneInput:focus,
.mm-input:focus {
    outline: none;
    border-color: var(--mm-primary);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15),
                0 4px 20px rgba(212, 175, 55, 0.2);
}

#phoneInput::placeholder,
.mm-input::placeholder {
    color: var(--mm-text-muted);
    letter-spacing: normal;
    font-weight: 400;
}

/* === 找到會員 === */
.mm-found {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--mm-radius-sm);
    animation: mmFadeIn 0.3s ease;
}

.mm-found-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mm-found-info {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.mm-found-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--mm-text);
    margin-bottom: 0.25rem;
}

.mm-found-level {
    font-size: 0.85rem;
    color: var(--mm-text-muted);
}

/* === 新會員註冊 === */
.mm-new {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(212, 175, 55, 0.02));
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-sm);
    animation: mmFadeIn 0.3s ease;
}

.mm-new-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--mm-primary);
    margin-bottom: 1.25rem;
}

.mm-new .mm-input {
    margin-bottom: 0.75rem;
    text-align: left;
    letter-spacing: normal;
}

/* === 按鈕 === */
.mm-btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--mm-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mm-btn-primary {
    background: linear-gradient(135deg, var(--mm-primary), var(--mm-primary-dark));
    color: #000;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.mm-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.4);
}

.mm-btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--mm-text-muted);
}

.mm-btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--mm-text);
}

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

/* === 會員中心 Profile Header === */
.mm-profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: var(--mm-radius-sm);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.mm-profile-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    pointer-events: none;
}

.mm-avatar {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.mm-profile-info {
    flex: 1;
    min-width: 0;
}

.mm-profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mm-text);
    margin-bottom: 0.25rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mm-profile-level {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--mm-text);
}

.mm-discount-tag {
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--mm-text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* === 功能選單 Grid === */
.mm-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.mm-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--mm-radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.mm-menu-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
}

.mm-menu-icon {
    font-size: 1.5rem;
}

.mm-menu-label {
    font-size: 0.8rem;
    color: var(--mm-text-muted);
}

.mm-menu-count {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--mm-primary);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === 資訊卡片 === */
.mm-info-card {
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--mm-radius-sm);
    padding: 0.25rem;
    margin-bottom: 1.5rem;
}

.mm-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mm-info-row:last-child {
    border-bottom: none;
}

.mm-info-row span:first-child {
    color: var(--mm-text-muted);
    font-size: 0.9rem;
}

.mm-info-row span:last-child {
    color: var(--mm-text);
    font-weight: 500;
}

/* === 管理功能區 === */
.mm-admin-section {
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1.5rem;
}

.mm-section-title {
    font-size: 0.75rem;
    color: var(--mm-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.75rem;
}

.mm-admin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.mm-admin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: var(--mm-radius-sm);
    color: var(--mm-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mm-admin-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
}

/* === 操作按鈕區 === */
.mm-actions {
    display: flex;
    gap: 0.75rem;
}

.mm-actions .mm-btn {
    flex: 1;
}

/* === 子頁面 Header === */
.mm-view-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--mm-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mm-back {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--mm-text);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mm-back:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-3px);
}

/* === 子頁面 Body === */
.mm-view-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* === 列表 === */
.mm-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.mm-list::-webkit-scrollbar {
    width: 4px;
}

.mm-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.mm-list::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 2px;
}

.mm-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--mm-radius-sm);
    transition: all 0.25s ease;
}

.mm-list-item:hover {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.12);
}

.mm-list-item.default {
    border-color: rgba(212, 175, 55, 0.4);
    background: rgba(212, 175, 55, 0.05);
}

.mm-item-info {
    flex: 1;
    min-width: 0;
}

.mm-item-name {
    font-weight: 600;
    color: var(--mm-text);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mm-item-meta {
    font-size: 0.85rem;
    color: var(--mm-text-muted);
}

.mm-item-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--mm-primary);
    white-space: nowrap;
}

.mm-item-address {
    font-size: 0.85rem;
    color: var(--mm-text-muted);
    margin-top: 0.35rem;
}

.mm-default-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--mm-primary);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #000;
}

.mm-item-delete {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 8px;
    color: var(--mm-danger);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mm-item-delete:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: scale(1.1);
}

/* === 空狀態 === */
.mm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--mm-text-muted);
    text-align: center;
}

.mm-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* === 表單 === */
.mm-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mm-form .mm-input {
    text-align: left;
    letter-spacing: normal;
}

/* === Toast 通知 === */
.mm-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.95);
    color: var(--mm-text);
    padding: 1rem 2rem;
    border-radius: var(--mm-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10001;
    border: 1px solid var(--mm-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

/* === Header 會員狀態 === */
.mm-status-name {
    color: var(--mm-primary);
    font-weight: 600;
}

.mm-status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin-left: 0.5rem;
}

/* === 產品收藏按鈕 === */
.favorite-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.favorite-btn:hover {
    transform: scale(1.15);
    background: rgba(0, 0, 0, 0.8);
}

.favorite-btn.active {
    background: rgba(239, 68, 68, 0.3);
    animation: mmHeartPop 0.4s ease;
}

/* === Header 會員按鈕（舊版相容） === */
.member-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.member-mode-btn {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.member-mode-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.5);
    color: #fff;
}

.member-status {
    padding: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
}

.member-status:hover {
    background: rgba(212, 175, 55, 0.2);
}

.member-status.logged-in {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    padding: 0;
}

/* === 動畫 === */
@keyframes mmFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes mmSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes mmHeartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* === RWD 響應式 === */
@media (max-width: 480px) {
    .mm-container {
        width: 95%;
        max-height: 95vh;
    }

    .mm-view {
        padding: 1.25rem;
    }

    .mm-profile-header {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

    .mm-profile-info {
        text-align: center;
    }

    .mm-menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mm-admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mm-actions {
        flex-direction: column;
    }

    .mm-profile-name {
        font-size: 1.25rem;
    }
}
