/* ============================================
   MADU ATTENDANCE PORTAL - GOLDEN RATIO DESIGN
   Version: 3.1.0 | Author: Manh Duc MCI
   ============================================ */

/* 📱 CONTAINER CẤP CAO NHẤT */
.madu-portal-container {
    background: linear-gradient(135deg, var(--color-white) 0%, var(--color-bg) 100%);
    min-height: 100vh;
    width: 100%;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    position: relative;
}

/* 🌈 TAB NAVIGATION - Thanh điều hướng tab */
.portal-tabs-navigation {
    background: var(--color-white);
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

.tabs-container {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.tab-button {
    /* Tỷ lệ vàng cho nút: chiều cao = chiều rộng / 1.618 */
    padding: var(--space-sm) calc(var(--space-md) * var(--golden-ratio));
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-light);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    position: relative;
    overflow: hidden;
}

.tab-button:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(232, 197, 71, 0.1), transparent);
    transition: left 0.5s ease;
}

.tab-button:hover:before {
    left: 100%;
}

.tab-button:hover {
    background: var(--color-white);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-secondary);
}

.tab-button.active {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #FFD700 100%);
    color: var(--color-primary);
    border-color: transparent;
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
}

/* 📊 TAB CONTENT - Nội dung tab */
.portal-tabs-content {
    padding: var(--space-lg);
    animation: fadeIn 0.5s ease;
    max-width: 100%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content {
    display: none;
    animation: slideIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 📈 HISTORY SECTION - Phần lịch sử */
.madu-history-section {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-xl);
    position: relative;
    overflow: hidden;
}

/* Hiệu ứng ánh vàng sang trọng */
.madu-history-section:before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(232, 197, 71, 0.05) 0%, transparent 70%);
    z-index: 0;
}

/* HEADER SECTION - Tiêu đề trang */
.history-page-header {
    text-align: center;
    margin-bottom: calc(var(--space-lg) * var(--golden-ratio));
    padding-bottom: var(--space-md);
    border-bottom: 3px solid var(--color-secondary);
    position: relative;
    z-index: 1;
}

.history-page-header h1 {
    font-size: var(--scale-4);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
    font-weight: 800;
}

.page-description {
    color: var(--color-text-light);
    font-size: var(--scale-1);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* FILTER SECTION - Bộ lọc */
.history-filters {
    background: linear-gradient(135deg, var(--color-bg) 0%, #F8F9FA 100%);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--color-border);
    position: relative;
    z-index: 1;
}

.filter-form {
    width: 100%;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-group label {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.filter-group input,
.filter-group select {
    padding: calc(var(--space-sm) * var(--golden-ratio)) var(--space-md);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--scale-1);
    transition: all var(--transition-fast);
    background: var(--color-white);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(232, 197, 71, 0.1);
}

/* BUTTONS - Nút bấm */
.btn-filter,
.btn-reset,
.btn-back-home,
.btn-print,
.btn-export {
    padding: calc(var(--space-sm) * var(--golden-ratio)) calc(var(--space-md) * var(--golden-ratio));
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-filter {
    background: linear-gradient(135deg, var(--color-accent) 0%, #2980B9 100%);
    color: white;
}

.btn-reset {
    background: linear-gradient(135deg, #95A5A6 0%, #7F8C8D 100%);
    color: white;
}

.btn-back-home {
    background: linear-gradient(135deg, var(--color-primary) 0%, #34495E 100%);
    color: white;
    text-decoration: none;
}

.btn-print {
    background: linear-gradient(135deg, #27AE60 0%, #229954 100%);
    color: white;
}

.btn-export {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
    color: white;
}

/* Hiệu ứng hover cho nút */
.btn-filter:hover,
.btn-reset:hover,
.btn-back-home:hover,
.btn-print:hover,
.btn-export:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.btn-filter:active,
.btn-reset:active,
.btn-back-home:active,
.btn-print:active,
.btn-export:active {
    transform: translateY(0) scale(0.98);
}

/* STATS GRID - Lưới thống kê */
.history-stats {
    margin: var(--space-lg) 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: linear-gradient(135deg, var(--color-white) 0%, #F8F9FA 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-secondary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover:before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-secondary);
}

.stat-card.highlight {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(41, 128, 185, 0.05) 100%);
    border-color: var(--color-accent);
}

.stat-icon {
    width: calc(var(--space-lg) * var(--golden-ratio));
    height: calc(var(--space-lg) * var(--golden-ratio));
    background: linear-gradient(135deg, var(--color-secondary) 0%, #FFD700 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: var(--scale-2);
    margin-bottom: var(--space-sm);
}

.stat-value {
    font-size: var(--scale-3);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-label {
    color: var(--color-text-light);
    font-size: 0.9rem;
    font-weight: 500;
}

/* TABLE CONTAINER - Bảng dữ liệu */
.history-table-container {
    margin-top: var(--space-lg);
    background: var(--color-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--color-secondary) var(--color-border);
}

.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--color-border);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: 4px;
}

/* MAIN TABLE - Bảng chính */
.madu-history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1000px;
    font-size: var(--scale-1);
}

.madu-history-table th {
    background: linear-gradient(135deg, var(--color-primary) 0%, #34495E 100%);
    color: var(--color-white);
    padding: calc(var(--space-sm) * var(--golden-ratio)) var(--space-md);
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--color-secondary);
}

.madu-history-table th:after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-secondary);
    opacity: 0.5;
}

.madu-history-table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    transition: background-color var(--transition-fast);
}

.madu-history-table tr:hover td {
    background-color: rgba(232, 197, 71, 0.05);
}

/* TABLE CELL STYLES - Kiểu ô bảng */
.date-cell { min-width: 120px; }
.hours-cell, .ot-cell { min-width: 80px; text-align: center; }
.salary-cell, .meal-cell, .advance-cell { min-width: 100px; text-align: right; }
.income-cell { min-width: 120px; text-align: right; font-weight: 600; }
.project-cell { min-width: 150px; }
.status-cell { min-width: 100px; }
.action-cell { min-width: 150px; }

/* BADGES - Nhãn trạng thái */
.status-badge {
    padding: calc(var(--space-xs) * var(--golden-ratio)) var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    white-space: nowrap;
}

.status-approved {
    background: linear-gradient(135deg, #27AE60 0%, #229954 100%);
    color: white;
}

.status-pending {
    background: linear-gradient(135deg, #E67E22 0%, #D35400 100%);
    color: white;
}

.ot-badge {
    background: linear-gradient(135deg, #3498DB 0%, #2980B9 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.advance-badge {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* INCOME COLORS - Màu thu nhập */
.income-amount.positive {
    color: #27AE60;
    background: rgba(39, 174, 96, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.income-amount.negative {
    color: #E74C3C;
    background: rgba(231, 76, 60, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    position: relative;
}

.income-amount.negative:hover:after {
    content: '⚠️ Tổng ứng > Tổng lương';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 5px;
}

/* ACTION BUTTONS - Nút hành động */
.action-buttons {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
}

.btn-view-detail {
    background: linear-gradient(135deg, var(--color-accent) 0%, #2980B9 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-view-detail:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.image-indicator {
    color: var(--color-secondary);
    font-size: 1.1rem;
    cursor: help;
}

/* PAGINATION - Phân trang */
.history-pagination {
    display: flex;
    justify-content: center;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
}

.history-pagination .page-numbers {
    display: flex;
    gap: var(--space-xs);
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-pagination .page-numbers li a,
.history-pagination .page-numbers li span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(var(--space-lg) * var(--golden-ratio));
    height: calc(var(--space-lg) * var(--golden-ratio));
    background: var(--color-bg);
    color: var(--color-text);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.history-pagination .page-numbers li a:hover {
    background: var(--color-secondary);
    color: var(--color-primary);
    transform: translateY(-2px);
}

.history-pagination .page-numbers .current {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #FFD700 100%);
    color: var(--color-primary);
}

/* NO DATA STATE - Trạng thái không có dữ liệu */
.no-history {
    text-align: center;
    padding: calc(var(--space-xl) * var(--golden-ratio)) var(--space-lg);
    background: linear-gradient(135deg, var(--color-bg) 0%, #F8F9FA 100%);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--color-border);
    margin: var(--space-lg) 0;
}

.no-history-icon {
    font-size: 4rem;
    color: var(--color-border);
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.no-history h4 {
    color: var(--color-text-light);
    margin-bottom: var(--space-sm);
}

/* MODAL - Hộp thoại */
#madu-detail-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 62, 80, 0.9);
    z-index: 9999;
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    margin: 5vh auto;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.4s ease;
    position: relative;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, #34495E 100%);
    color: white;
    padding: var(--space-lg);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.close-modal {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* RESPONSIVE DESIGN - Thiết kế đáp ứng */

/* Tablet (768px và nhỏ hơn) */
@media (max-width: 768px) {
    .portal-tabs-content {
        padding: var(--space-md);
    }
    
    .madu-history-section {
        padding: var(--space-md);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }
    
    .filter-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .tab-button {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.9rem;
    }
    
    .history-page-header h1 {
        font-size: var(--scale-3);
    }
}

/* Mobile (480px và nhỏ hơn) */
@media (max-width: 480px) {
    :root {
        --base-size: 14px;
        --space-unit: 6px;
    }
    
    .portal-tabs-content {
        padding: var(--space-sm);
    }
    
    .madu-history-section {
        padding: var(--space-sm);
        border-radius: var(--radius-lg);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: var(--space-sm);
    }
    
    .tab-button {
        flex: 1;
        min-width: 120px;
        justify-content: center;
        font-size: 0.85rem;
    }
    
    .tabs-container {
        padding: var(--space-xs);
    }
    
    .modal-content {
        width: 95%;
        margin: 2vh auto;
    }
}

/* Desktop lớn (1200px và lớn hơn) */
@media (min-width: 1200px) {
    .portal-tabs-content {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .madu-history-section {
        border-radius: var(--radius-xl);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* PRINT STYLES - Kiểu in ấn */
@media print {
    .portal-tabs-navigation,
    .history-filters,
    .btn-print,
    .btn-export,
    .action-buttons {
        display: none !important;
    }
    
    .madu-history-section {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    .madu-history-table th {
        background: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* UTILITY CLASSES - Lớp tiện ích */
.text-gradient {
    background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.golden-shadow {
    box-shadow: 0 8px 32px rgba(232, 197, 71, 0.15);
}

.border-golden {
    border: 2px solid var(--color-secondary);
}

/* LOADING ANIMATION - Hiệu ứng tải */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* FADE ANIMATION - Hiệu ứng mờ dần */
.fade-in {
    animation: fadeIn 0.5s ease;
}

/* GOLDEN HIGHLIGHT - Điểm nhấn vàng */
.golden-highlight {
    position: relative;
}

.golden-highlight:before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--color-secondary) 0%, transparent 100%);
    opacity: 0.5;
}

/* NOTE: Các giá trị sử dụng tỷ lệ vàng (1.618) để đảm bảo tính thẩm mỹ */
/* Màu sắc chủ đạo: Xanh thanh lịch (#2C3E50) + Vàng điểm nhấn (#E8C547) */
/* Tất cả khoảng cách đều tuân theo tỷ lệ vàng để tạo sự hài hòa */
/* Animation mượt mà với transition 0.3s ease */
/* Responsive hoàn chỉnh từ mobile đến desktop */