/* public/assets/css/components/profile-view.css */

/* --- Main Container & Loading --- */
.profile-view {
    /* Styles for the main view container */
}

.loading-overlay { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 400px; 
}

.loading-spinner { 
    width: 40px; 
    height: 40px; 
    border: 4px solid var(--border); 
    border-top-color: var(--primary); 
    border-radius: 50%; 
    animation: spin 1s linear infinite; 
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Tab Navigation --- */
.profile-tabs { 
    display: flex; 
    background-color: var(--bg); 
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 0.5rem; 
    margin-bottom: 2rem; 
    border: 1px solid var(--border); 
    border-top: none;
    position: sticky;
    top: 0;
    z-index: 10;
}


.tab-link { 
    flex: 1; 
    padding: 0.75rem 1rem; 
    cursor: pointer; 
    border: none; 
    background: transparent; 
    color: var(--muted); 
    font-weight: 600; 
    border-radius: 8px; 
    transition: all 0.2s ease-in-out; 
    text-align: center; 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-link:hover:not(.active) { 
    background-color: color-mix(in srgb, var(--text) 5%, transparent); 
    color: var(--text); 
}

.tab-link.active { 
    background: var(--surface); 
    color: var(--primary); 
    box-shadow: var(--shadow); 
}

/* --- General Section Styling --- */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.5s ease; }

.profile-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.profile-section h2 { 
    display: flex; 
    align-items: center; 
    gap: .75rem; 
    font-size: 1.5rem; 
    font-weight: 700;
    margin: 0 0 2rem 0; 
    color: var(--text);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.profile-section h3 { 
    font-size: 1.2rem; 
    font-weight: 600; 
    margin: 2.5rem 0 1.5rem 0; 
    color: var(--text-secondary); 
}
.profile-section h3:first-of-type {
    margin-top: 0;
}


/* --- Performance Tab --- */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 1.5rem; 
}

.stat-card { 
    display: flex; 
    align-items: center; 
    gap: 1.25rem; 
    padding: 1.5rem; 
    border-radius: var(--radius); 
    color: #fff; 
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon { 
    width: 48px; 
    height: 48px; 
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
}
.stat-icon .feather {
    width: 24px;
    height: 24px;
}
.stat-value { 
    font-size: 2rem; 
    font-weight: 700; 
    display: block; 
    line-height: 1; 
}
.stat-label { 
    font-size: 0.9rem; 
    opacity: 0.9; 
    margin-top: 0.25rem;
    display: block;
}
.stat-card.color-1 { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.stat-card.color-2 { background: linear-gradient(135deg, #10b981, #34d399); }
.stat-card.color-3 { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.stat-card.color-4 { background: linear-gradient(135deg, #f59e0b, #facc15); }

/* --- Chart Styling --- */
.chart-container { 
    height: 350px; 
    padding: 1.5rem; 
    background: var(--bg); 
    border-radius: var(--radius); 
    border: 1px solid var(--border); 
}

/* --- History Tab --- */
.history-controls { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 1.5rem; 
    margin-bottom: 1.5rem;
    flex-wrap: wrap; 
}

/* --- MODIFICATION START: This is the definitive fix for the search bar --- */
.search-wrapper { 
    position: relative; 
    flex-grow: 1; 
    min-width: 250px; 
    display: flex; /* Force flex layout */
    align-items: center; /* Vertically align items */
    background: var(--bg); /* Match input background */
    border: 1px solid var(--border); /* Match input border */
    border-radius: 8px; /* Match input radius */
}

.search-wrapper i { 
    flex-shrink: 0; /* Prevent icon from shrinking */
    padding-left: 14px; /* Space on the left */
    color: var(--muted); 
    width: 18px; 
}

#history-search-input { 
    width: 100%; 
    padding: 0.75rem 1rem;
    border: none; /* Remove border from input itself */
    background: transparent; /* Make input background transparent */
    color: var(--text); 
    font-size: 0.9rem;
}
#history-search-input:focus {
    outline: none; /* Remove focus outline */
}
/* --- MODIFICATION END --- */

.quiz-history-filters { 
    display: flex; 
    gap: 0.5rem; 
    background: var(--bg);
    border-radius: 8px;
    padding: 0.25rem;
    border: 1px solid var(--border);
}
.filter-pill { 
    padding: 0.5rem 1rem; 
    border-radius: 6px; 
    border: none; 
    color: var(--muted); 
    cursor: pointer; 
    transition: all 0.2s ease;
    font-weight: 500;
    background: transparent;
}
.filter-pill.active { 
    background: var(--primary); 
    color: #fff; 
    box-shadow: var(--shadow-sm);
}
.table-container { overflow-x: auto; }
.history-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 0.9rem;
}
.history-table th, .history-table td { 
    padding: 0.75rem 1rem; 
    text-align: left; 
    border-bottom: 1px solid var(--border); 
    vertical-align: middle; 
}
.history-table th { 
    font-weight: 600; 
    color: var(--muted); 
    white-space: nowrap; 
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mode-test, .mode-practice { 
    padding: 0.25rem 0.75rem; 
    border-radius: 99px; 
    font-weight: 600; 
    font-size: 0.75rem;
}
.mode-test { 
    color: var(--warning); 
    background-color: color-mix(in srgb, var(--warning) 15%, transparent); 
}
.mode-practice { 
    color: var(--success); 
    background-color: color-mix(in srgb, var(--success) 15%, transparent); 
}
.history-footer { 
    text-align: center; 
    margin-top: 2rem; 
}
.action-cell { text-align: right; }
.btn-retake { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    transition: all 0.2s ease; 
    border: 1px solid var(--border); 
    background: var(--bg);
    margin-left: 0.5rem; 
}
.btn-retake:hover { 
    transform: scale(1.1); 
    box-shadow: var(--shadow); 
}
.btn-retake.test { color: var(--warning); }
.btn-retake.practice { color: var(--success); }
.btn-retake.test:hover { background-color: color-mix(in srgb, var(--warning) 15%, transparent); }
.btn-retake.practice:hover { background-color: color-mix(in srgb, var(--success) 15%, transparent); }

/* --- Badges & Payment Tabs --- */
.badges-container { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); 
    gap: 2rem; 
    text-align: center; 
}
.badge-item { 
    position: relative; 
    cursor: pointer; 
}
.badge-item:hover img { transform: scale(1.1) rotate(5deg); }
.badge-item img { 
    width: 80px; 
    height: 80px; 
    transition: transform 0.2s ease;
    margin-bottom: 0.75rem;
}
.badge-item p { 
    font-weight: 600; 
    font-size: .9rem; 
}
.badge-tooltip { 
    position: absolute; 
    bottom: 110%; 
    left: 50%; 
    transform: translateX(-50%); 
    background: var(--text-primary); 
    color: var(--surface); 
    padding: 0.5rem 0.75rem; 
    border-radius: 6px; 
    font-size: 0.8rem; 
    width: max-content; 
    max-width: 220px; 
    opacity: 0; 
    visibility: hidden; 
    transition: all 0.2s ease; 
    z-index: 10;
    box-shadow: var(--shadow-lg);
}
.badge-item:hover .badge-tooltip { opacity: 1; visibility: visible; }

.subscription-status { 
    background: var(--bg); 
    padding: 1.5rem; 
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.plan-expiry { 
    font-size: 0.9rem; 
    color: var(--success); 
}
.subscription-badge { 
    display: inline-flex; 
    align-items: center; 
    gap: .5rem; 
    padding: .4rem 1rem; 
    border-radius: 999px; 
    font-weight: 600; 
}
.subscription-badge.pro { 
    background: var(--warning); 
    color: #fff; 
}
.subscription-badge.free { 
    background: var(--border); 
    color: var(--muted); 
}

/* --- General --- */
.empty-state { 
    text-align: center; 
    padding: 3rem; 
    color: var(--muted);
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
}
.error-message { 
    color: var(--error); 
    padding: 1rem; 
    background: var(--error-light); 
    border: 1px solid var(--error); 
    border-radius: var(--radius); 
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
    .profile-section {
        padding: 1.5rem;
    }
    .profile-tabs {
        flex-direction: column;
    }
    .history-controls {
        flex-direction: column;
        align-items: stretch;
    }
}