/* ==== CSS CHÍNH CHO HỆ THỐNG ĐIỂM DANH ==== */

/* Bảng điểm danh */
#checkin_table.table-checkin {
    border-collapse: collapse;
    width: 100%;
}

#checkin_table.table-checkin thead th {
    background: #e7e7e7;
    color: #333;
    font-weight: 600;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    white-space: nowrap;
}

#checkin_table.table-checkin tbody td {
    background: #f5f5f5;
    padding: 9px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

#checkin_table.table-checkin tbody tr:nth-child(even) {
    background: #fafafa;
}

#checkin_table.table-checkin tbody tr:hover {
    background: #f1f7ff;
}

#checkin_table.table-checkin img {
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ==== LỊCH ĐIỂM DANH ==== */
.checkin-calendar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.calendar-day {
    width: calc(20% - 12px);
    min-width: 180px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.calendar-day:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.calendar-day.current {
    border-color: #4CAF50;
    background: #f8fff8;
}

.calendar-day.checked {
    border-color: #2196F3;
    background: #f5faff;
}

.calendar-day.future {
    opacity: 0.7;
    border-style: dashed;
}

/* Header ngày */
.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.day-number {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.day-status {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-checked { background: #4CAF50; color: white; }
.status-available { background: #2196F3; color: white; }
.status-future { background: #9e9e9e; color: white; }

/* Phần thưởng trong ngày */
.day-rewards {
    min-height: 120px;
}

.reward-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 5px;
    background: #f9f9f9;
    border-radius: 5px;
}

.reward-item img {
    width: 32px;
    height: 32px;
    margin-right: 8px;
    border-radius: 4px;
}

.reward-info {
    flex: 1;
    font-size: 13px;
}

.reward-name {
    font-weight: 600;
    color: #333;
}

.reward-stats {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

/* Tổng kết ngày */
.day-summary {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #666;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

/* ==== ĐIỀU KHIỂN LỊCH ==== */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.current-month-display {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #eaeaea;
    min-width: 250px;
    transition: all 0.3s ease;
}

.current-month-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.calendar-icon {
    color: #4CAF50;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-info {
    display: flex;
    flex-direction: column;
}

.month-info .label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.month-info .date {
    font-size: 20px;
    font-weight: 700;
    color: #2196F3;
    line-height: 1.2;
    background: linear-gradient(90deg, #2196F3, #4CAF50);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Thống kê */
.calendar-stats {
    display: flex;
    gap: 20px;
}

.stat-box {
    text-align: center;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #2196F3;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* ==== HỆ THỐNG TÍCH LŨY ==== */
.accumulative-container {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.accumulative-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.accumulative-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.accumulative-icon {
    font-size: 20px;
}

.accumulative-title {
    font-size: 16px;
    font-weight: 600;
}

.accumulative-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Tiến độ */
.milestone-progress {
    margin-bottom: 10px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-label {
    font-size: 13px;
    opacity: 0.9;
}

.progress-count {
    font-size: 13px;
    font-weight: bold;
}

.progress-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f093fb, #f5576c);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.next-milestone-info {
    font-size: 12px;
    text-align: center;
    font-style: italic;
    opacity: 0.9;
}

/* Phần thưởng tiếp theo */
.next-rewards {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.rewards-label {
    font-size: 12px;
    margin-bottom: 5px;
    opacity: 0.9;
}

.rewards-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reward-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.reward-gold { background: #FFD700; color: #333; }
.reward-money { background: #4CAF50; color: white; }
.reward-coin { background: #2196F3; color: white; }
.reward-item-badge { background: #eef0f0; color: white; }

/* Các loại mốc */
.achieved-milestone,
.achieved-streak {
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9) !important;
    border-left: 4px solid #4CAF50 !important;
}

.claimable-milestone {
    background: linear-gradient(135deg, #fff3e0, #ffecb3) !important;
    border-left: 4px solid #FF9800 !important;
}

.upcoming-milestone,
.upcoming-streak {
    background: linear-gradient(135deg, #f5f5f5, #eeeeee) !important;
    border-left: 4px solid #9E9E9E !important;
}

/* ==== CHUỖI ĐIỂM DANH ==== */
.streak-container {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    border-radius: 10px;
    color: #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 154, 158, 0.3);
}

.streak-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.streak-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.streak-icon {
    font-size: 20px;
}

.streak-title {
    font-size: 16px;
    font-weight: 600;
}

.claimable-streak {
    background: linear-gradient(135deg, #f1f8e9, #dcedc8) !important;
    border-left: 4px solid #2196F3 !important;
    animation: streakPulse 2s infinite;
}

.current-streak-row {
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
    border: 2px solid #FF9800 !important;
}

/* CSS cho phần reset tháng */
.month-reset-info {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    border: 2px solid #ffb300;
    border-radius: 10px;
    padding: 12px 15px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(255, 179, 0, 0.15);
    animation: gentleGlow 3s infinite alternate;
}

.month-reset-info .reset-icon {
    font-size: 24px;
    color: #ff8f00;
    animation: spinSlow 4s linear infinite;
}

.month-reset-info .reset-text {
    font-size: 14px;
    font-weight: 600;
    color: #5d4037;
    flex: 1;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

/* ==== ANIMATIONS ==== */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes bonusPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes spinSlow {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-10deg); }
    100% { transform: rotate(0deg); }
}

@keyframes gentleGlow {
    0% { box-shadow: 0 4px 12px rgba(255, 179, 0, 0.15); border-color: #ffb300; }
    100% { box-shadow: 0 4px 18px rgba(255, 179, 0, 0.25); border-color: #ff9800; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes streakPulse {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes completedPulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.05); opacity: 1; }
}

.can-claim {
    animation: pulse 2s infinite;
    border: 2px solid #FF9800 !important;
}

.claim-button {
    cursor: pointer;
    transition: all 0.3s ease;
}

.claim-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.3);
}

/* ==== NÚT TÍCH LŨY VÀ CHUỖI ==== */
.btn-claim-milestone {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex !important; /* THÊM FLEX */
    align-items: center !important; /* THÊM */
    justify-content: center !important; /* THÊM */
    width: 100%;
    max-width: 120px;
    margin: 0 auto !important; /* THÊM */
    text-transform: uppercase;
    letter-spacing: 0.8px;
    min-height: 38px;
    line-height: 1.4;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.btn-claim-milestone:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.4);
    background: linear-gradient(135deg, #27ae60, #219653);
}

.btn-claim-milestone:active {
    transform: translateY(-1px);
}

/* Tiến độ thống nhất */
.milestone-progress {
    min-width: 160px;
}

.progress-container {
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 6px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 12px;
    position: relative;
}

#milestone_table .progress-bar {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
}

#streak_table .progress-bar {
    background: linear-gradient(90deg, #FF9800, #F57C00);
}

.progress-bar:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(255, 255, 255, 0.2) 100%);
    animation: shimmer 2s infinite;
}

.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: black;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.progress-percent {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: #666;
}

.progress-text.completed {
    background: linear-gradient(135deg, rgba(0,0,0,0.1), rgba(0,0,0,0.2));
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    animation: completedPulse 1.5s infinite alternate;
}

#milestone_table .progress-text.completed {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
}

#streak_table .progress-text.completed {
    background: linear-gradient(135deg, #FF9800, #F57C00);
}

/* ==== NÚT ĐIỂM DANH VÀ TRỞ VỀ ==== */
.xac_nhan .col8.left0 {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 20px;
    width: 100%;
}

/* CSS CHUNG CHO CẢ HAI NÚT ĐIỂM DANH VÀ TRỞ VỀ */
.btn_xn {
    display: flex !important; /* THAY ĐỔI TỪ inline-flex */
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 140px;
    height: 46px;
    padding: 12px 28px;
    line-height: 22px;
    box-sizing: border-box;
    font-family: inherit;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #4CAF50;
    color: white;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    margin: 0;
}

/* Nút Điểm danh */
#checkinBtn {
    font-size: 15px;
    font-weight: 600;
}

/* Nút Trở về - chữ nhỏ hơn */
.xac_nhan .col8.left0 a.btn_xn {
    font-size: 14px;
    font-weight: 500;
}

/* Hiệu ứng hover */
#checkinBtn:hover:not(:disabled),
.xac_nhan .col8.left0 a.btn_xn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    background: #45a049;
    opacity: 0.95;
}

/* Nút disabled */
#checkinBtn:disabled {
    background: #8DC73F;
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Active state */
#checkinBtn:active:not(:disabled),
.xac_nhan .col8.left0 a.btn_xn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.2);
    background: #3d8b40;
}

/* Focus state */
#checkinBtn:focus,
.xac_nhan .col8.left0 a.btn_xn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.4);
}

/* Thông báo lỗi */
#checkinError {
    width: 100%;
    margin-top: 15px;
    text-align: center;
    padding: 10px;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    display: none;
    order: 3;
}

/* ==== FIX CĂN GIỮA CHO TẤT CẢ NÚT ==== */
/* Đảm bảo tất cả nút trong bảng đều căn giữa */
#milestone_table tr td:nth-child(3),
#streak_table tr td:nth-child(3) {
    text-align: center !important;
    padding: 15px 5px !important;
}

/* Đảm bảo nút Nhận ngay trong bảng căn giữa */
#milestone_table tr td:nth-child(3) .btn-claim-milestone,
#streak_table tr td:nth-child(3) .btn_xn.primary {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
    text-align: center !important;
}

/* Đảm bảo tất cả phần tử trong ô căn giữa */
#milestone_table tr td:nth-child(3) *,
#streak_table tr td:nth-child(3) * {
    margin-left: auto !important;
    margin-right: auto !important;
    float: none !important;
    display: block !important;
}

/* ==== RESPONSIVE DESIGN ==== */

/* Desktop lớn */
@media (max-width: 1200px) {
    .calendar-day { width: calc(25% - 12px); }
}

/* Tablet ngang */
@media (max-width: 992px) {
    .calendar-day { width: calc(33.333% - 12px); }
}

/* Tablet dọc */
@media (max-width: 768px) {
    .calendar-day { width: calc(50% - 12px); }
    
    .calendar-controls {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
    }
    
    .current-month-display {
        min-width: 100%;
        justify-content: center;
    }
    
    .month-nav {
        width: 100%;
        justify-content: center;
    }
    
    .calendar-stats {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .month-info .date { font-size: 18px; }
}

/* Mobile */
@media (max-width: 576px) {
    .calendar-day { width: 100%; }
    
    .calendar-stats {
        gap: 10px;
    }
    
    .stat-box {
        min-width: calc(33.333% - 10px);
        padding: 8px 10px;
    }
    
    .current-month-display {
        padding: 12px 20px;
    }
    
    .month-info .date { font-size: 16px; }
    
    .form_napthe .col3,
    .form_napthe .col5,
    .form_napthe .col4 {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .captcha { margin-top: 10px; }
    
    /* Nút trên mobile */
    .xac_nhan .col8.left0 {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn_xn {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        font-size: 15px;
        padding: 14px 20px;
    }
    
    .xac_nhan .col8.left0 a.btn_xn {
        font-size: 14.5px;
    }
}

/* Mobile nhỏ */
@media (max-width: 400px) {
    .calendar-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .stat-box { width: 100%; }
    
    .current-month-display {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .month-info { align-items: center; }
}

/* Loading và trạng thái */
.checkin-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.checkin-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 15px;
    border-radius: 5px;
    margin: 10px 0;
}

.checkin-success {
    background: #efe;
    border: 1px solid #cfc;
    color: #0a0;
    padding: 15px;
    border-radius: 5px;
    margin: 10px 0;
}

/* Tooltip */
.checkin-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.checkin-tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.checkin-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Dark mode (tùy chọn) */
@media (prefers-color-scheme: dark) {
    .calendar-day {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .day-number {
        color: #e2e8f0;
    }
    
    .reward-item {
        background: #4a5568;
    }
    
    .reward-name {
        color: #e2e8f0;
    }
    
    .stat-box {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .stat-value {
        color: #63b3ed;
    }
    
    .stat-label {
        color: #a0aec0;
    }
}