/**
 * 帳號資訊頁面 - 修煉證書風格
 * 神社 RPG 風格的個人檔案卡
 */

/* --- 整體容器 --- */
.profile-container {
    max-width: 600px;
    margin: 40px auto;
    padding: 20px;
    font-family: 'Yuji Syuku', serif;
}

/* --- 角色卡片本體 --- */
.character-card {
    background-color: #FFFBF0;
    border: 4px solid #5d4037;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 10px 10px 0 rgba(93, 64, 55, 0.2);
    position: relative;
}

/* --- 頂部橫樑裝飾 --- */
.card-header-beam {
    background: linear-gradient(to right, #5d4037, #8d6e63);
    color: #FFFBF0;
    padding: 8px 16px;
    text-align: center;
    border-bottom: 2px solid #3e2723;
}

.shrine-badge {
    font-size: 14px;
    letter-spacing: 2px;
    opacity: 0.9;
}

/* --- 英雄區 (頭貼+名字) --- */
.character-hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    background-image: radial-gradient(#e6ded3 1px, transparent 1px);
    background-size: 20px 20px;
}

/* --- 頭貼互動區 --- */
.avatar-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    background: #fff;
    /* overflow: hidden 移除，讓 level-badge 可以顯示在外面 */
}

.avatar-wrapper:hover {
    transform: scale(1.05);
    border-color: #c62828;
}

.current-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* 懸停時出現的黑色遮罩 */
.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
    color: white;
    border-radius: 50%;
}

.avatar-wrapper:hover .avatar-overlay {
    opacity: 1;
}

.edit-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.edit-text {
    font-size: 12px;
    font-weight: bold;
}

/* 等級標籤 - 顯示在頭像外面右下角 */
.level-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #c62828;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    border: 2px solid #fff;
    font-weight: bold;
    z-index: 10;
}

/* --- 名字資訊 --- */
.character-info {
    text-align: center;
    margin-top: 15px;
}

.username {
    margin: 0;
    color: #3e2723;
    font-size: 24px;
}

.user-title {
    color: #8d6e63;
    font-size: 14px;
    margin: 5px 0;
    font-weight: bold;
}

.join-date {
    color: #a1887f;
    font-size: 12px;
    margin: 0;
}

/* --- 進度提示 --- */
.progress-hint {
    padding: 15px 30px;
    text-align: center;
}

.progress-hint.hidden {
    display: none;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0d6cc;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #8d6e63, #5d4037);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    color: #8d6e63;
    font-size: 12px;
    margin: 0;
}

.progress-text .highlight {
    color: #5d4037;
    font-weight: bold;
}

/* 已達最高等級時的特殊樣式 */
.progress-hint.max-level .progress-bar {
    background: linear-gradient(90deg, #c62828, #ff5252);
}

.progress-hint.max-level .progress-text {
    color: #c62828;
    font-weight: bold;
}

/* --- 分隔線 --- */
.divider-line {
    height: 2px;
    background: linear-gradient(to right, transparent, #d7ccc8, transparent);
    margin: 0 20px;
}

/* --- 數據欄 (Stats Grid) --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    padding: 20px;
    background: #fff;
    border-top: 2px dashed #d7ccc8;
    border-bottom: 2px dashed #d7ccc8;
}

.stat-item {
    text-align: center;
}

.stat-icon {
    font-size: 20px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 22px;
    font-weight: 900;
    color: #5d4037;
}

.stat-label {
    font-size: 12px;
    color: #8d6e63;
}

/* --- 底部詳細資料 --- */
.account-details {
    padding: 25px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    border-bottom: 1px solid #efebe9;
    padding-bottom: 8px;
    font-size: 14px;
}

.detail-row .label {
    color: #8d6e63;
}

.detail-row .value {
    color: #3e2723;
    font-weight: bold;
}

/* 按鈕美化 */
.action-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.btn-primary-profile {
    flex: 2;
    background: #5d4037;
    color: #fff;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Yuji Syuku', serif;
    font-size: 14px;
    transition: background 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn-secondary-profile {
    flex: 1;
    background: transparent;
    color: #5d4037;
    border: 2px solid #5d4037;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Yuji Syuku', serif;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s;
}

.btn-primary-profile:hover {
    background: #4e342e;
}

.btn-secondary-profile:hover {
    background: #efebe9;
}

/* --- 頭像選擇 Modal --- */
.avatar-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.avatar-modal.hidden {
    display: none;
}

.avatar-modal-content {
    background: #FFFBF0;
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 4px solid #5d4037;
}

.avatar-modal-title {
    margin: 0 0 20px 0;
    color: #5d4037;
    text-align: center;
    font-size: 18px;
}

.avatar-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    justify-items: center;
    margin-bottom: 20px;
}

.avatar-option {
    cursor: pointer;
    text-align: center;
    padding: 12px 16px;
    border-radius: 12px;
    border: 3px solid transparent;
    transition: all 0.2s;
    background: #fff;
    width: 100%;
    max-width: 140px;
}

.avatar-option:hover {
    border-color: #c62828;
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(198, 40, 40, 0.2);
}

.avatar-option.selected {
    border-color: #c62828;
    background: #fff5f5;
}

.avatar-option img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    margin: 0 auto 8px;
}

.avatar-option span {
    font-size: 14px;
    color: #5d4037;
    font-weight: 500;
}

.avatar-modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.avatar-modal-cancel {
    flex: 1;
    padding: 12px;
    background: #e0e0e0;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Yuji Syuku', serif;
    cursor: pointer;
    transition: background 0.2s;
}

.avatar-modal-cancel:hover {
    background: #d0d0d0;
}

.avatar-modal-confirm {
    flex: 1;
    padding: 12px;
    background: #5d4037;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Yuji Syuku', serif;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.avatar-modal-confirm:hover:not(:disabled) {
    background: #4e342e;
}

.avatar-modal-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- 登入提示 (未登入狀態) --- */
.login-prompt-card {
    background-color: #FFFBF0;
    border: 4px solid #5d4037;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 10px 10px 0 rgba(93, 64, 55, 0.2);
}

.login-prompt-card h2 {
    color: #5d4037;
    margin: 0 0 15px 0;
}

.login-prompt-card p {
    color: #8d6e63;
    margin: 0 0 25px 0;
    line-height: 1.6;
}

.login-prompt-card .login-btn {
    display: inline-block;
    background: #5d4037;
    color: #FFFBF0;
    padding: 12px 30px;
    border-radius: 8px;
    text-decoration: none;
    font-family: 'Yuji Syuku', serif;
    transition: background 0.2s;
}

.login-prompt-card .login-btn:hover {
    background: #4e342e;
}

/* --- PC版微調 --- */
@media (min-width: 600px) {
    .character-hero-section {
        flex-direction: row;
        text-align: left;
        gap: 25px;
    }
    
    .character-info {
        text-align: left;
        margin-top: 0;
    }
    
    .avatar-wrapper {
        flex-shrink: 0;
    }
}

/* --- 手機版微調 --- */
@media (max-width: 480px) {
    .profile-container {
        padding: 10px;
        margin: 20px auto;
    }
    
    .character-card {
        box-shadow: 5px 5px 0 rgba(93, 64, 55, 0.2);
    }
    
    .stats-grid {
        gap: 5px;
        padding: 15px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-primary-profile,
    .btn-secondary-profile {
        flex: none;
    }
    
    .avatar-options {
        gap: 10px;
    }
    
    .avatar-option img {
        width: 60px;
        height: 60px;
    }
}
