/**
 * Workspace / Bảng điều khiển CSS
 * Modern dashboard layout with card-based design
 */

/* ═══════════════════════════════════════════════════════════════════════════
   WORKSPACE CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */

.workspace-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - 80px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   WORKSPACE HEADER
   ═══════════════════════════════════════════════════════════════════════════ */

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.workspace-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color, #1f2937);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.workspace-title h1 i {
    color: var(--primary-color, #3b82f6);
}

.workspace-subtitle {
    color: var(--text-secondary, #6b7280);
    margin: 4px 0 0 0;
    font-size: 0.9rem;
}

.workspace-actions {
    display: flex;
    gap: 12px;
}

.btn-refresh {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-color: var(--primary-color, #3b82f6);
}

.btn-refresh.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   WORKSPACE GRID
   ═══════════════════════════════════════════════════════════════════════════ */

.workspace-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WORKSPACE CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.workspace-card {
    background: var(--bg-card, #fff);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.workspace-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.card-header h2 i {
    color: var(--primary-color, #3b82f6);
    font-size: 1.1rem;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    text-align: center;
}

/* Card Action Buttons */
.btn-edit, .btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-edit {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-secondary, #6b7280);
    border: 1px solid var(--border-color, #e5e7eb);
}

.btn-edit:hover {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-color: var(--primary-color, #3b82f6);
}

.btn-action {
    background: var(--primary-color, #3b82f6);
    color: white;
}

.btn-action:hover {
    background: var(--primary-dark, #2563eb);
}

/* ═══════════════════════════════════════════════════════════════════════════
   USER INFO CARD
   ═══════════════════════════════════════════════════════════════════════════ */

.user-info-card {
    grid-column: span 2;
}

.user-profile-display {
    display: flex;
    align-items: center;
    gap: 24px;
}

.user-avatar-wrapper {
    flex-shrink: 0;
}

.user-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color, #3b82f6);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.user-details-display {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.user-detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.detail-label {
    color: var(--text-secondary, #6b7280);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-label i {
    width: 16px;
    text-align: center;
}

.detail-value {
    font-weight: 600;
    color: var(--text-color, #1f2937);
}

.sso-notice {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-info, #eff6ff);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
}

.sso-notice i {
    color: var(--primary-color, #3b82f6);
}

.sso-notice a {
    color: var(--primary-color, #3b82f6);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS CARD
   ═══════════════════════════════════════════════════════════════════════════ */

.progress-card {
    grid-column: span 2;
}

.progress-stats {
    display: flex;
    justify-content: space-around;
    gap: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    margin-bottom: 20px;
}

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

.stat-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--primary-color, #3b82f6) var(--progress, 0%), var(--bg-secondary, #e5e7eb) 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    position: relative;
}

.stat-circle::before {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    background: var(--bg-card, #fff);
    border-radius: 50%;
}

.stat-circle .stat-number {
    position: relative;
    z-index: 1;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color, #3b82f6);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color, #1f2937);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

.level-progress h4 {
    font-size: 0.9rem;
    color: var(--text-secondary, #6b7280);
    margin: 0 0 16px 0;
}

.level-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.level-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.level-label {
    width: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color, #1f2937);
}

.level-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-secondary, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
}

.level-bar-fill {
    height: 100%;
    background: var(--primary-color, #3b82f6);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.level-percent {
    width: 40px;
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EXAM HISTORY & LESSONS CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.exam-list, .lessons-list, .favorites-list {
    max-height: 350px;
    overflow-y: auto;
}

.exam-item, .lesson-item, .favorite-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
    gap: 12px;
}

.exam-item:hover, .lesson-item:hover, .favorite-item:hover {
    background: var(--bg-secondary, #f9fafb);
}

.exam-item + .exam-item,
.lesson-item + .lesson-item,
.favorite-item + .favorite-item {
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.exam-icon, .lesson-icon, .favorite-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.exam-icon {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
}

.lesson-icon {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
}

.favorite-icon {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: white;
}

.exam-info, .lesson-info, .favorite-info {
    flex: 1;
    min-width: 0;
}

.exam-title, .lesson-title, .favorite-title {
    font-weight: 600;
    color: var(--text-color, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.exam-meta, .lesson-meta, .favorite-meta {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    display: flex;
    gap: 12px;
}

.exam-score {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--bg-secondary, #f3f4f6);
}

.exam-score.high { color: #10b981; background: #d1fae5; }
.exam-score.medium { color: #f59e0b; background: #fef3c7; }
.exam-score.low { color: #ef4444; background: #fee2e2; }

.btn-load-more {
    background: none;
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-secondary, #6b7280);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-load-more:hover {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-color: var(--primary-color, #3b82f6);
}

/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE & LOADING
   ═══════════════════════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary, #6b7280);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    margin: 0 0 16px;
}

.btn-explore {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary-color, #3b82f6);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.btn-explore:hover {
    background: var(--primary-dark, #2563eb);
}

.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-secondary, #6b7280);
}

.loading-placeholder i {
    font-size: 1.2rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    
    .user-info-card,
    .progress-card {
        grid-column: span 1;
    }
    
    .progress-stats {
        flex-wrap: wrap;
    }
    
    .stat-item {
        flex: 1 1 calc(50% - 12px);
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .workspace-container {
        padding: 16px;
    }
    
    .workspace-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .workspace-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .user-profile-display {
        flex-direction: column;
        text-align: center;
    }
    
    .user-details-display {
        justify-content: center;
    }
    
    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .card-header .btn-action,
    .card-header .btn-edit {
        width: 100%;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════════════════════════════ */

[data-theme="dark"] {
    --bg-card: #1f2937;
    --bg-secondary: #374151;
    --text-color: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #4b5563;
    --bg-info: #1e3a5f;
}

[data-theme="dark"] .workspace-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .exam-score {
    background: var(--bg-secondary);
}

[data-theme="dark"] .exam-score.high { background: #065f46; }
[data-theme="dark"] .exam-score.medium { background: #78350f; }
[data-theme="dark"] .exam-score.low { background: #7f1d1d; }
