/* Profile Page Styles */

/* Container */
.profile-container {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 1rem;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(10, 10, 10, 0.85);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Profile Header */
.profile-header {
    background: var(--component-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.profile-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #2a6b6c, #3d9a9b);
}

.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.profile-avatar-large {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: 0 4px 16px rgba(24, 66, 67, 0.15);
    flex-shrink: 0;
    background: var(--bg);
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-info h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.profile-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    direction: ltr;
    text-align: right;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Profile Content */
.profile-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Section Card */
.profile-section {
    background: var(--component-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.section-title svg {
    color: var(--primary);
    flex-shrink: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 12px rgba(24, 66, 67, 0.08);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(24, 66, 67, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.stat-icon.usage-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Usage Bar */
.usage-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.usage-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #3d9a9b);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Preferences Form */
.preferences-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preference-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.preference-item:last-of-type {
    border-bottom: none;
}

.preference-item label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.preference-item select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
    transition: border-color 0.2s;
}

.preference-item select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 66, 67, 0.1);
}

.save-preferences-btn {
    align-self: flex-start;
    padding: 0.7rem 2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.save-preferences-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Activity / History */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.activity-item:hover {
    border-color: var(--primary);
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(24, 66, 67, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
}

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

.view-all-btn {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    margin-top: 0.75rem;
}

.view-all-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
}

/* Export Buttons */
.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.export-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.export-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.export-btn.primary:hover {
    background: var(--primary-hover);
}

.export-btn svg {
    flex-shrink: 0;
}

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

.modal-content {
    background: var(--component-bg);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

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

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: 8px;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.full-history-list {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.history-type {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    background: rgba(24, 66, 67, 0.1);
    color: var(--primary);
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-input {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.history-output {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.5;
    padding: 0.75rem;
    background: var(--component-bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.copy-history-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.copy-history-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.loading-text,
.empty-state,
.error-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 600px) {
    .profile-container {
        padding: 1rem 1rem 3rem;
    }

    .profile-header {
        padding: 1.5rem;
    }

    .profile-avatar-section {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }

    .profile-info {
        text-align: center;
    }

    .profile-info p {
        text-align: center;
    }

    .logout-btn {
        margin-top: 0.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .export-buttons {
        flex-direction: column;
    }

    .preference-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .preference-item select {
        width: 100%;
    }
}