/* profile.css */

/* Profile Header - Complete Redesign */
.profile-header {
    position: relative;
    margin-bottom: 32px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.profile-cover {
    height: 200px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    position: relative;
    overflow: hidden;
}

.profile-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.15;
    background-image: radial-gradient(circle at 2px 2px, white 1px, transparent 0);
    background-size: 32px 32px;
}

/* Main info container - Flexbox layout */
.profile-info {
    display: flex;
    align-items: flex-end;
    padding: 0 32px 24px;
    margin-top: -50px;
    position: relative;
    z-index: 1;
    gap: 24px;
}

/* Avatar section */
.profile-avatar-section {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    border: 5px solid var(--bg-primary);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.avatar-edit-btn:hover {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: white;
}

.avatar-edit-btn svg,
.avatar-edit-btn i {
    width: 18px;
    height: 18px;
}

/* Profile details - text content */
.profile-details {
    flex: 1;
    padding-bottom: 8px;
    min-width: 0; /* Allows text truncation */
}

.profile-details h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    line-height: 1.2;
    word-wrap: break-word;
}

.profile-email {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.profile-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Profile actions - button area */
.profile-actions {
    padding-bottom: 8px;
    flex-shrink: 0;
}

.profile-actions .btn {
    white-space: nowrap;
}

/* Role badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.role-badge.paid {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.role-badge.free {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

/* Profile Stats */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.profile-stats .stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.profile-stats .stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.profile-stats .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-stats .stat-icon.blue {
    background: #dbeafe;
    color: #1e40af;
}

.profile-stats .stat-icon.green {
    background: #d1fae5;
    color: #047857;
}

.profile-stats .stat-icon.purple {
    background: #ede9fe;
    color: #5b21b6;
}

.profile-stats .stat-icon.orange {
    background: #fef3c7;
    color: #b45309;
}

.profile-stats .stat-icon i {
    width: 24px;
    height: 24px;
}

.profile-stats .stat-info {
    flex: 1;
}

.profile-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.profile-stats .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Profile Grid */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.profile-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
}

.profile-section.full-width {
    grid-column: span 2;
}

.profile-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-section h3 i {
    width: 20px;
    height: 20px;
    color: var(--primary-600);
}

.profile-bio {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 20px;
    font-size: 0.9375rem;
}

.profile-bio p {
    margin: 0;
}

.profile-info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.info-item i {
    width: 18px;
    height: 18px;
    color: var(--primary-600);
    flex-shrink: 0;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 260px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.activity-item:hover {
    background: var(--bg-tertiary);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}

.activity-icon i {
    width: 20px;
    height: 20px;
    color: var(--primary-600);
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Quiz History Table */
.quiz-history-table {
    overflow-x: auto;
}

.quiz-history-table .data-table {
    width: 100%;
    border-collapse: collapse;
}

.quiz-history-table th,
.quiz-history-table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.9375rem;
}

.quiz-history-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.quiz-history-table td {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.quiz-history-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-close svg,
.modal-close i {
    width: 24px;
    height: 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

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

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-input[readonly] {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 0.9375rem;
}

/* Responsive - Tablet */
@media (max-width: 1200px) {
    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .profile-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0 20px 24px;
        gap: 16px;
    }
    
    .profile-avatar {
        width: 100px;
        height: 100px;
        font-size: 2rem;
    }
    
    .profile-details {
        text-align: center;
        padding-bottom: 0;
    }
    
    .profile-details h1 {
        font-size: 1.5rem;
    }
    
    .profile-badges {
        justify-content: center;
    }
    
    .profile-actions {
        padding-bottom: 0;
        width: 100%;
    }
    
    .profile-actions .btn {
        width: 100%;
    }
    
    .profile-stats {
        grid-template-columns: 1fr;
    }
    
    .profile-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-section.full-width {
        grid-column: span 1;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
    .profile-cover {
        height: 150px;
    }
    
    .profile-info {
        margin-top: -40px;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 1.5rem;
    }
    
    .avatar-edit-btn {
        width: 30px;
        height: 30px;
        bottom: 4px;
        right: 4px;
    }
}

/* Profile mobile production polish */
@media (max-width: 768px) {
    .profile-header {
        margin-bottom: 20px;
        border-radius: 22px;
    }

    .profile-cover {
        height: 170px;
    }

    .profile-info {
        margin-top: -48px;
        padding: 0 18px 22px;
        gap: 12px;
    }

    .profile-avatar {
        width: 96px;
        height: 96px;
        border-width: 4px;
        font-size: 1.9rem;
    }

    .avatar-edit-btn {
        width: 34px;
        height: 34px;
        right: 4px;
        bottom: 4px;
    }

    .profile-details h1 {
        font-size: 1.75rem;
        overflow-wrap: anywhere;
    }

    .profile-email {
        font-size: 0.98rem;
        overflow-wrap: anywhere;
    }

    .profile-badges {
        gap: 8px;
    }

    .profile-actions .btn {
        min-height: 48px;
        justify-content: center;
    }

    .profile-stats {
        gap: 12px;
        margin-bottom: 20px;
    }

    .profile-stats .stat-card {
        min-height: 96px;
        padding: 16px;
        border-radius: 18px;
    }

    .profile-stats .stat-icon {
        width: 52px;
        height: 52px;
        flex-shrink: 0;
    }

    .profile-stats .stat-info,
    .profile-section,
    .activity-content,
    .info-item span {
        min-width: 0;
    }

    .profile-stats .stat-value,
    .profile-stats .stat-label,
    .profile-bio,
    .info-item span {
        overflow-wrap: anywhere;
    }

    .profile-grid {
        gap: 16px;
    }

    .profile-section {
        padding: 18px;
        border-radius: 20px;
    }

    .profile-section h3 {
        margin-bottom: 16px;
        font-size: 1.05rem;
        line-height: 1.25;
    }

    .activity-list {
        max-height: none;
        overflow: visible;
        gap: 10px;
    }

    .activity-item {
        align-items: flex-start;
        padding: 12px;
        border-radius: 16px;
    }

    .activity-icon {
        flex-shrink: 0;
    }

    .activity-text {
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    .quiz-history-table {
        overflow: visible;
    }

    .quiz-history-table .data-table,
    .quiz-history-table thead,
    .quiz-history-table tbody,
    .quiz-history-table tr,
    .quiz-history-table th,
    .quiz-history-table td {
        display: block;
        width: 100%;
    }

    .quiz-history-table thead {
        display: none;
    }

    .quiz-history-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .quiz-history-table tbody tr {
        display: grid;
        gap: 8px;
        padding: 14px;
        border: 1px solid var(--border-color);
        border-radius: 16px;
        background: var(--bg-secondary);
    }

    .quiz-history-table tbody tr:hover {
        background: var(--bg-secondary);
    }

    .quiz-history-table td {
        display: grid;
        grid-template-columns: 86px minmax(0, 1fr);
        gap: 10px;
        padding: 0;
        border-bottom: 0;
        font-size: 0.92rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .quiz-history-table td::before {
        color: var(--text-tertiary);
        font-weight: 700;
    }

    .quiz-history-table td:nth-child(1)::before {
        content: "Test";
    }

    .quiz-history-table td:nth-child(2)::before {
        content: "Materie";
    }

    .quiz-history-table td:nth-child(3)::before {
        content: "Scor";
    }

    .quiz-history-table td:nth-child(4)::before {
        content: "Data";
    }

    .quiz-history-table td:nth-child(5)::before {
        content: "Status";
    }

    .quiz-history-table td.empty-state {
        display: block;
        text-align: center;
    }

    .quiz-history-table td.empty-state::before {
        content: none;
    }

    .modal-overlay {
        padding: 12px;
        align-items: stretch;
    }

    .modal-content {
        max-width: none;
        max-height: calc(100dvh - 24px);
        border-radius: 20px;
    }

    .modal-header,
    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .profile-header {
        border-radius: 20px;
    }

    .profile-cover {
        height: 132px;
    }

    .profile-info {
        margin-top: -40px;
        padding: 0 16px 20px;
    }

    .profile-avatar {
        width: 82px;
        height: 82px;
        font-size: 1.5rem;
    }

    .profile-details h1 {
        font-size: 1.55rem;
    }

    .profile-email {
        font-size: 0.92rem;
    }

    .role-badge,
    .status-badge {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .profile-stats .stat-card {
        min-height: 88px;
        padding: 14px;
    }

    .profile-stats .stat-icon {
        width: 48px;
        height: 48px;
    }

    .profile-section {
        padding: 16px;
        border-radius: 18px;
    }

    .quiz-history-table td {
        grid-template-columns: 74px minmax(0, 1fr);
        font-size: 0.88rem;
    }
}
