/**
 * AffiTrack Frontend Styles
 * 
 * @package AffiTrack
 * @since 1.0.0
 */

/* AffiTrack Container */
.affitrack-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Leaderboard Styles */
.affitrack-leaderboard {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.leaderboard-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.leaderboard-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.leaderboard-filters {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.leaderboard-filters select,
.leaderboard-filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.leaderboard-list {
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.leaderboard-item:hover {
    background-color: #f8f9fa;
}

.leaderboard-item.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
}

.leaderboard-item.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #e5e5e5 100%);
}

.leaderboard-item.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #daa520 100%);
}

.rank-badge {
    margin-right: 15px;
    font-size: 20px;
}

.badge {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
    font-weight: bold;
    font-size: 14px;
}

.badge.gold {
    background: #ffd700;
    color: #333;
}

.badge.silver {
    background: #c0c0c0;
    color: #333;
}

.badge.bronze {
    background: #cd7f32;
    color: white;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 5px;
}

.user-stats {
    display: flex;
    gap: 15px;
    font-size: 14px;
    color: #666;
}

.user-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Login Form Styles */
.affitrack-login-container {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.affitrack-login-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.affitrack-login-header h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
}

.affitrack-login-form {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.form-checkbox input[type="checkbox"] {
    width: auto;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
}

.btn-success {
    background: #28a745;
}

.btn-danger {
    background: #dc3545;
}

/* Enhanced Frontend Styles */

/* Stats Cards Enhancement */
.affitrack-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.affitrack-stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-align: left;
}

.affitrack-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.affitrack-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.affitrack-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 16px;
}

.affitrack-stat-content {
    display: flex;
    flex-direction: column;
}

.affitrack-stat-number {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    line-height: 1;
    margin-bottom: 4px;
}

.affitrack-stat-label {
    font-size: 14px;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Table Enhancement */
.affitrack-links-table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.affitrack-links-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.affitrack-links-table thead th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    border-bottom: 2px solid #dee2e6;
    position: relative;
}

.affitrack-links-table tbody tr {
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f1f3f4;
}

.affitrack-links-table tbody tr:hover {
    background-color: #f8f9fa;
}

.affitrack-links-table tbody tr:last-child {
    border-bottom: none;
}

.affitrack-links-table td {
    padding: 16px 12px;
    vertical-align: middle;
    font-size: 14px;
}

.affitrack-link-code {
    background: #f1f3f4;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    color: #495057;
    border: 1px solid #e9ecef;
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.affitrack-copy-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.affitrack-copy-btn:hover {
    background: #e3f2fd;
    color: #1976d2;
}

.affitrack-number {
    font-weight: 600;
    color: #2d3748;
}

.affitrack-rate {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    min-width: 50px;
    display: inline-block;
}

.affitrack-rate-high {
    background: #c6f6d5;
    color: #22543d;
}

.affitrack-rate-medium {
    background: #feebc8;
    color: #c05621;
}

.affitrack-rate-low {
    background: #fed7d7;
    color: #c53030;
}

/* Button Enhancements */
.affitrack-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.affitrack-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.affitrack-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    color: white;
}

.affitrack-btn-secondary {
    background: #718096;
    color: white;
    box-shadow: 0 2px 8px rgba(113, 128, 150, 0.2);
}

.affitrack-btn-secondary:hover {
    background: #4a5568;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(113, 128, 150, 0.3);
}

.affitrack-btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Profile Section Enhancements */
.affitrack-profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.affitrack-profile-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #667eea;
    object-fit: cover;
}

.affitrack-profile-name {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 4px 0;
}

.affitrack-profile-email {
    color: #718096;
    margin: 0 0 8px 0;
    font-size: 14px;
}

.affitrack-profile-since {
    color: #a0aec0;
    margin: 0;
    font-size: 12px;
}

.affitrack-rank-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin-left: auto;
}

.affitrack-rank-number {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.affitrack-rank-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Charts Section */
.affitrack-charts-section {
    margin-top: 32px;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.affitrack-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.affitrack-section-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

.affitrack-toggle-charts {
    background: none;
    border: 1px solid #e2e8f0;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.affitrack-toggle-charts:hover {
    background: #667eea;
    color: white;
}

.affitrack-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.affitrack-chart-wrapper {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Action Buttons Section */
.affitrack-profile-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .affitrack-profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .affitrack-rank-badge {
        margin: 16px 0 0 0;
    }
}

@media (max-width: 768px) {
    .affitrack-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
    }
    
    .affitrack-stat-card {
        padding: 20px;
        text-align: left;
    }
    
    .affitrack-stat-number {
        font-size: 24px;
    }
    
    .affitrack-profile-header {
        padding: 20px;
        gap: 16px;
    }
    
    .affitrack-profile-name {
        font-size: 20px;
    }
    
    .affitrack-links-table-wrapper {
        overflow-x: auto;
    }
    
    .affitrack-links-table {
        min-width: 800px;
    }
    
    .affitrack-charts-grid {
        grid-template-columns: 1fr;
    }
    
    .affitrack-profile-actions {
        flex-direction: column;
    }
    
    .affitrack-profile-actions .affitrack-btn {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .affitrack-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .affitrack-stat-card {
        padding: 16px;
        text-align: left;
    }
    
    .affitrack-profile-header {
        padding: 16px;
    }
    
    .affitrack-links-table th,
    .affitrack-links-table td {
        padding: 12px 8px;
        font-size: 12px;
    }
    
    .affitrack-link-code {
        max-width: 120px;
        font-size: 10px;
    }
}

/* Animation Utilities */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.affitrack-fade-in {
    animation: fadeInUp 0.3s ease-out;
}

/* Loading States */
.affitrack-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #718096;
    font-size: 14px;
}

.affitrack-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* User Profile Styles */
.affitrack-profile {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.profile-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.profile-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 600;
}

.profile-header p {
    margin: 0;
    opacity: 0.9;
}

.profile-content {
    padding: 30px;
}

.profile-section {
    margin-bottom: 30px;
}

.profile-section h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: left;
    border: 1px solid #e9ecef;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #667eea;
    display: block;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.links-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.links-table th,
.links-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.links-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.links-table tr:hover {
    background: #f8f9fa;
}

.charts-container {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.chart-wrapper {
    margin-bottom: 30px;
}

.chart-wrapper h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #333;
}

/* Alert Styles */
.affitrack-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

.alert-success {
    background: #28a745;
}

.alert-error {
    background: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .affitrack-container {
        padding: 10px;
    }
    
    .leaderboard-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .leaderboard-item {
        flex-direction: column;
        text-align: center;
    }
    
    .rank-badge {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .user-stats {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .links-table {
        font-size: 14px;
    }
    
    .links-table th,
    .links-table td {
        padding: 8px;
    }
}

/* Custom Colors */
:root {
    --affitrack-primary: #667eea;
    --affitrack-secondary: #764ba2;
    --affitrack-success: #28a745;
    --affitrack-danger: #dc3545;
    --affitrack-warning: #ffc107;
    --affitrack-info: #17a2b8;
}

/* Dark Mode Support - COMMENTED OUT TO AVOID CONFLICTS */
/*
@media (prefers-color-scheme: dark) {
    .affitrack-leaderboard,
    .affitrack-login-container,
    .affitrack-profile {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .leaderboard-filters {
        background: #4a5568;
        border-color: #718096;
    }
    
    .leaderboard-item {
        border-color: #4a5568;
    }
    
    .leaderboard-item:hover {
        background-color: #4a5568;
    }
    
    .form-group input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .stat-card {
        background: #4a5568;
        border-color: #718096;
    }
    
    .links-table th {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .links-table tr:hover {
        background: #4a5568;
    }
}
*/

/* Commission Hidden State - Ẩn hoàn toàn */
.affitrack-hide-commission .commission,
.affitrack-hide-commission .total-commission,
.affitrack-hide-commission .revenue,
.affitrack-hide-commission [class*="commission"],
.affitrack-hide-commission [class*="revenue"] {
    display: none !important;
}

/* Điều chỉnh layout khi ẩn commission */
.affitrack-hide-commission .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}

.affitrack-hide-commission .affitrack-stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}

/* Hide commission values when setting is enabled - handled via PHP */ 