/* 統一通用樣式模版 */
/* 適用於所有頁面的通用樣式 */

/* ==================== 佈局樣式 ==================== */

/* 側邊欄樣式 */
.sidebar {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 25%; /* col-md-3 的寬度 */
    z-index: 1000;
    overflow-y: auto;
}

/* 主要內容區樣式 */
.main-content {
    background-color: #f8f9fa;
    min-height: 100vh;
    overflow-y: auto;
    margin-left: 25%; /* 為側邊欄留出空間 */
    width: 75%; /* col-md-9 的寬度 */
}

/* 行和列樣式 */
.row {
    margin: 0;
}

/* 恢復Bootstrap網格系統的預設填充 */
.col-md-3, .col-md-9, .col-lg-2, .col-lg-10 {
    padding-left: 15px;
    padding-right: 15px;
}

/* ==================== 卡片樣式 ==================== */

.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

/* ==================== 按鈕樣式 ==================== */

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.btn-custom {
    border-radius: 10px;
    padding: 8px 20px;
    font-weight: 500;
}

/* ==================== 導航樣式 ==================== */

.nav-link {
    color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    margin: 8px 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    text-decoration: none;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.nav-link:hover, .nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-left: 4px solid rgba(255, 255, 255, 0.8);
}

.nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.nav-link:hover i, .nav-link.active i {
    transform: scale(1.1);
    color: #fff;
}

/* 導航項目文字樣式 */
.nav-link span {
    flex: 1;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

/* 導航項目懸停效果 */
.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.nav-link:hover::before {
    left: 100%;
}

/* 特殊導航項目樣式 */
.nav-link[href*="dashboard"] i {
    color: #ffd700;
}

.nav-link[href*="daily-tasks"] i {
    color: #4CAF50;
}

.nav-link[href*="health-data"] i {
    color: #f44336;
}

.nav-link[href*="weight-loss"] i {
    color: #ff9800;
}

.nav-link[href*="online-learning"] i {
    color: #2196F3;
}

.nav-link[href*="video-learning"] i {
    color: #9C27B0;
}

.nav-link[href*="points-management"] i {
    color: #FFC107;
}

.nav-link[href*="profile"] i {
    color: #00BCD4;
}

.nav-link[onclick*="switchToAdminPanel"] i {
    color: #607D8B;
}

/* ==================== 用戶資訊樣式 ==================== */

.user-info {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin: 15px;
    color: white;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

/* 用戶資訊文字樣式 */
.user-info h6 {
    margin-bottom: 0;
    font-weight: 500;
}

.user-info small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

/* 用戶積分顯示樣式 */
.user-points {
    text-align: center;
    margin-top: 10px;
}

.user-points .points-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 0;
}

.user-points .points-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    margin-bottom: 0;
}

/* 用戶等級樣式 */
.user-level {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    font-weight: 500;
}

/* ==================== 表單樣式 ==================== */

.form-control, .form-select {
    border-radius: 10px;
    border: 2px solid #e9ecef;
    transition: border-color 0.3s;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* ==================== 進度條樣式 ==================== */

.progress {
    height: 8px;
    border-radius: 4px;
}

/* ==================== 警告容器樣式 ==================== */

.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    max-width: 400px;
}

/* ==================== 響應式設計 ==================== */

@media (max-width: 768px) {
    .user-info {
        margin: 10px;
        padding: 12px;
    }
    
    .user-avatar {
        width: 35px;
        height: 35px;
        border-width: 2px;
    }
    
    /* 手機版：側邊欄變為正常流，主要內容區全寬 */
    .sidebar {
        position: relative;
        height: auto;
        min-height: auto;
        width: 100%;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    /* 手機版導航樣式調整 */
    .nav-link {
        padding: 10px 12px;
        margin: 4px 0;
    }
    
    .nav-link i {
        width: 20px;
        margin-right: 8px;
        font-size: 1rem;
    }
    
    .nav-link span {
        font-size: 0.9rem;
    }
}

/* 平板尺寸響應式設計 */
@media (min-width: 769px) and (max-width: 991px) {
    .nav-link {
        padding: 10px 14px;
        margin: 6px 0;
    }
    
    .nav-link i {
        width: 22px;
        margin-right: 10px;
    }
    
    .nav-link span {
        font-size: 0.9rem;
    }
}

/* 大螢幕響應式設計 */
@media (min-width: 992px) {
    .sidebar {
        width: 16.666667%; /* col-lg-2 的寬度 */
    }
    
    .main-content {
        margin-left: 16.666667%;
        width: 83.333333%; /* col-lg-10 的寬度 */
    }
}

/* ==================== 深色主題適配 ==================== */

@media (prefers-color-scheme: dark) {
    .user-info {
        background: rgba(0, 0, 0, 0.2);
    }
    
    .user-avatar {
        border-color: rgba(255, 255, 255, 0.4);
    }
    
    .main-content {
        background-color: #1a1a1a;
        color: #ffffff;
    }
    
    /* 卡片深色主題適配 */
    .card {
        background: #2d2d2d;
        color: #ffffff;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
    
    .card-body {
        color: #ffffff;
    }
    
    .card-title {
        color: #ffffff;
    }
    
    .card-text {
        color: #b0b0b0;
    }
    
    .card-header {
        background: #3d3d3d;
        border-bottom: 1px solid #555555;
        color: #ffffff;
    }
    
    .card-footer {
        background: #3d3d3d;
        border-top: 1px solid #555555;
        color: #ffffff;
    }
    
    /* 表單元素深色主題適配 */
    .form-control, .form-select {
        background: #3d3d3d;
        border-color: #555555;
        color: #ffffff;
    }
    
    .form-control:focus, .form-select:focus {
        background: #3d3d3d;
        border-color: #64b5f6;
        color: #ffffff;
        box-shadow: 0 0 0 0.2rem rgba(100, 181, 246, 0.25);
    }
    
    .form-control::placeholder {
        color: #888888;
    }
    
    /* 表格深色主題適配 */
    .table {
        color: #ffffff;
    }
    
    .table th {
        background: #3d3d3d;
        color: #ffffff;
        border-color: #555555;
    }
    
    .table td {
        color: #ffffff;
        border-color: #555555;
    }
    
    .table tbody tr:hover {
        background: #3d3d3d;
    }
    
    /* 模態框深色主題適配 */
    .modal-content {
        background: #2d2d2d;
        color: #ffffff;
    }
    
    .modal-header {
        border-bottom: 1px solid #444444;
    }
    
    .modal-footer {
        border-top: 1px solid #444444;
    }
    
    .modal-title {
        color: #ffffff;
    }
    
    /* 按鈕深色主題適配 */
    .btn-outline-primary {
        color: #64b5f6;
        border-color: #64b5f6;
    }
    
    .btn-outline-primary:hover {
        background: #64b5f6;
        border-color: #64b5f6;
        color: #ffffff;
    }
    
    .btn-outline-secondary {
        color: #b0b0b0;
        border-color: #555555;
    }
    
    .btn-outline-secondary:hover {
        background: #555555;
        border-color: #555555;
        color: #ffffff;
    }
    
    .btn-outline-info {
        color: #64b5f6;
        border-color: #64b5f6;
    }
    
    .btn-outline-info:hover {
        background: #64b5f6;
        border-color: #64b5f6;
        color: #ffffff;
    }
    
    .btn-outline-success {
        color: #4caf50;
        border-color: #4caf50;
    }
    
    .btn-outline-success:hover {
        background: #4caf50;
        border-color: #4caf50;
        color: #ffffff;
    }
    
    .btn-outline-danger {
        color: #f44336;
        border-color: #f44336;
    }
    
    .btn-outline-danger:hover {
        background: #f44336;
        border-color: #f44336;
        color: #ffffff;
    }
    
    .btn-outline-warning {
        color: #ff9800;
        border-color: #ff9800;
    }
    
    .btn-outline-warning:hover {
        background: #ff9800;
        border-color: #ff9800;
        color: #ffffff;
    }
    
    /* 文字顏色適配 */
    .text-muted {
        color: #888888 !important;
    }
    
    .text-dark {
        color: #ffffff !important;
    }
    
    .text-light {
        color: #ffffff !important;
    }
    
    /* 背景顏色適配 */
    .bg-light {
        background-color: #3d3d3d !important;
        color: #ffffff !important;
    }
    
    .bg-white {
        background-color: #2d2d2d !important;
        color: #ffffff !important;
    }
    
    /* 分頁深色主題適配 */
    .pagination .page-link {
        background: #3d3d3d;
        border-color: #555555;
        color: #ffffff;
    }
    
    .pagination .page-link:hover {
        background: #555555;
        border-color: #555555;
        color: #ffffff;
    }
    
    .pagination .page-item.active .page-link {
        background: #64b5f6;
        border-color: #64b5f6;
        color: #ffffff;
    }
    
    /* 警告框深色主題適配 */
    .alert {
        border: 1px solid #555555;
    }
    
    .alert-info {
        background-color: #1a3a5c;
        border-color: #2c5aa0;
        color: #b3d9ff;
    }
    
    .alert-success {
        background-color: #1a4d1a;
        border-color: #2e7d32;
        color: #c8e6c9;
    }
    
    .alert-warning {
        background-color: #4d3a1a;
        border-color: #f57c00;
        color: #ffe0b2;
    }
    
    .alert-danger {
        background-color: #4d1a1a;
        border-color: #d32f2f;
        color: #ffcdd2;
    }
}

/* ==================== 特殊效果 ==================== */

/* 數據輸入區塊 */
.data-input {
    background: white;
    border-radius: 15px;
    padding: 20px;
}

/* 圖表容器 */
.chart-container {
    position: relative;
    height: 300px;
}

/* 推薦卡片 */
.recommendation-card {
    border-left: 4px solid #28a745;
}

.recommendation-card.warning {
    border-left-color: #ffc107;
}

.recommendation-card.danger {
    border-left-color: #dc3545;
}

/* 統計卡片 */
.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* 健康分數 */
.health-score {
    font-size: 3rem;
    font-weight: bold;
}

/* ==================== 管理員功能樣式 ==================== */

/* 管理員導航項目樣式 */
.nav-link.admin-only {
    display: none;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    border-left: 4px solid #ffc107;
    position: relative;
}

.nav-link.admin-only::before {
    content: 'ADMIN';
    position: absolute;
    top: -5px;
    right: 5px;
    background: #ffc107;
    color: #000;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}

.nav-link.admin-only:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
    transform: translateX(5px);
}

.nav-link.admin-only i {
    color: #ffc107;
}

/* 管理員功能顯示 */
body.admin-mode .nav-link.admin-only {
    display: flex;
}

/* 管理員模式指示器 */
.admin-indicator {
    position: fixed;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
    display: none;
}

body.admin-mode .admin-indicator {
    display: block;
}

/* 管理員功能動畫 */
@keyframes adminPulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.nav-link.admin-only:hover {
    animation: adminPulse 2s infinite;
}

/* ==================== 抽獎機樣式 ==================== */

/* 抽獎機主體 */
.reward-machine {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.machine-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* 顯示螢幕 */
.display-screen {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 3px solid #444;
    border-radius: 15px;
    width: 200px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.display-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: screenGlow 3s infinite;
}

@keyframes screenGlow {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.coin-slot {
    position: relative;
    z-index: 2;
}

/* 拉桿 */
.lever-container {
    position: relative;
}

.lever {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
    position: relative;
    overflow: hidden;
}

.lever::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.lever:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.6);
}

.lever:hover::before {
    transform: translateX(100%);
}

.lever:active {
    transform: scale(0.95);
}

/* 抽獎動畫 */
@keyframes coinSpin {
    0% { transform: rotateY(0deg) scale(1); }
    25% { transform: rotateY(90deg) scale(1.1); }
    50% { transform: rotateY(180deg) scale(1.2); }
    75% { transform: rotateY(270deg) scale(1.1); }
    100% { transform: rotateY(360deg) scale(1); }
}

@keyframes leverPull {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-20deg); }
    100% { transform: rotate(0deg); }
}

.coin-spinning {
    animation: coinSpin 2s ease-in-out;
}

.lever-pulling {
    animation: leverPull 0.5s ease-in-out;
}

/* 獎品顯示 */
.reward-prize {
    font-size: 3rem;
    margin: 20px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.reward-prize.gold {
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
}

.reward-prize.silver {
    color: #c0c0c0;
    text-shadow: 0 0 10px #c0c0c0;
}

/* 抽獎結果動畫 */
@keyframes resultPop {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(0deg); opacity: 0.8; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.reward-result-show {
    animation: resultPop 0.8s ease-out;
}

/* 積分不足提示 */
.insufficient-points {
    color: #e74c3c;
    font-weight: bold;
    margin-top: 10px;
}

/* 抽獎按鈕狀態 */
#drawButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#drawButton:not(:disabled) {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border: none;
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}

#drawButton:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.6);
}