/* frontend/css/profile-refactor.css */

/* --- Chips / Pills Styles --- */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 9999px; /* Pill shape */
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.chip:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

.chip.selected {
    background-color: var(--primary-color, #5D5FEF);
    color: white;
    border-color: var(--primary-color, #5D5FEF);
    box-shadow: 0 2px 4px rgba(93, 95, 239, 0.2);
}

.chip.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    pointer-events: none; /* Prevent clicks */
}

/* --- Height Input Group --- */
.height-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.height-field {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.height-field input {
    padding-right: 2rem !important; /* Make room for unit label */
    width: 100%;
}

.unit-label {
    position: absolute;
    right: 0.75rem;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: none;
}

/* --- Equipment Toggle --- */
.equipment-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.equipment-toggle {
    display: inline-flex;
    background-color: #f1f5f9;
    padding: 0.25rem;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
}

.equipment-toggle-btn {
    padding: 0.5rem 1.5rem;
    border-radius: 9999px;
    border: none;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.equipment-toggle-btn.active {
    background-color: white;
    color: var(--primary-color, #5D5FEF);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.equipment-toggle-btn i {
    margin-right: 0.5rem;
}

/* --- Weekly Schedule Selector --- */
.schedule-selector {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap; /* Allow wrap on small screens */
}

.day-checkbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.day-checkbox input {
    display: none; /* Hide default checkbox */
}

.day-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
}

.day-checkbox input:checked + .day-circle {
    background-color: var(--primary-color, #5D5FEF);
    color: white;
    border-color: var(--primary-color, #5D5FEF);
    box-shadow: 0 2px 5px rgba(93, 95, 239, 0.2);
}

.day-checkbox span {
    font-size: 0.75rem;
    color: #64748b;
}

/* --- Injury List Styles --- */
.injury-list-container {
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 1rem;
    background-color: #f8fafc;
    min-height: 100px;
    margin-top: 1rem;
}

.injury-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.injury-details {
    display: flex;
    flex-direction: column;
}

.injury-name {
    font-weight: 600;
    color: #334155;
}

.injury-meta {
    font-size: 0.85rem;
    color: #64748b;
}

.remove-injury-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
}

.remove-injury-btn:hover {
    color: #dc2626;
}

.add-injury-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.injury-input-group {
    flex: 1;
    min-width: 150px;
}

.injury-input-group label {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

/* --- Profile Avatar Styles --- */
.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--bg-secondary, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-right: 1.5rem;
    flex-shrink: 0;
    border: 3px solid white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

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

.profile-avatar i {
    font-size: 3rem;
    color: var(--text-secondary, #94a3b8);
}

/* --- Dark Mode Overrides (if needed) --- */
[data-theme="dark"] .chip {
    background-color: #334155;
    color: #e2e8f0;
    border-color: #475569;
}
[data-theme="dark"] .chip:hover {
    background-color: #475569;
}
[data-theme="dark"] .chip.selected {
    background-color: var(--primary-color);
    color: white;
}
[data-theme="dark"] .equipment-toggle {
    background-color: #334155;
    border-color: #475569;
}
[data-theme="dark"] .equipment-toggle-btn {
    color: #94a3b8;
}
[data-theme="dark"] .equipment-toggle-btn.active {
    background-color: #1e293b;
    color: var(--primary-color);
}
[data-theme="dark"] .day-circle {
    background-color: #334155;
    border-color: #475569;
    color: #cbd5e1;
}
[data-theme="dark"] .injury-list-container {
    background-color: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .injury-item {
    background-color: #334155;
    border-color: #475569;
}
[data-theme="dark"] .injury-name {
    color: #f1f5f9;
}
[data-theme="dark"] .profile-avatar {
    background-color: #334155;
    border-color: #1e293b;
}
[data-theme="dark"] .profile-avatar i {
    color: #94a3b8;
}

/* --- Achievements Styles --- */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.achievement-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.achievement-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.achievement-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.achievement-info h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: #334155;
}

.achievement-info p {
    margin: 0;
    font-size: 0.8rem;
    color: #64748b;
}

[data-theme="dark"] .achievement-card {
    background-color: #334155;
    border-color: #475569;
}
[data-theme="dark"] .achievement-info h4 {
    color: #f1f5f9;
}
[data-theme="dark"] .achievement-info p {
    color: #cbd5e1;
}

/* --- Layout & Structure (Restoring Missing Styles) --- */

.profile-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    width: 100%;
}

.profile-header {
    display: flex;
    align-items: center;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
}

.profile-username {
    font-size: 1rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.profile-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: #64748b;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Stat Cards --- */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
    border: 1px solid #e2e8f0;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color, #5D5FEF);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

/* --- Tabs Styling --- */

.tabs-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 2rem;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    overflow-x: auto;
}

.tab-button {
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-button:hover {
    color: #334155;
    background: #f1f5f9;
}

.tab-button.active {
    color: var(--primary-color, #5D5FEF);
    border-bottom-color: var(--primary-color, #5D5FEF);
    background: white;
}

.tab-content {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Form & Section Styles --- */

.profile-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.form-control input,
.form-control select {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control input:focus,
.form-control select:focus {
    border-color: var(--primary-color, #5D5FEF);
    outline: none;
    box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.1);
}

.form-value {
    padding: 0.6rem 0;
    font-size: 1rem;
    color: #334155;
    font-weight: 500;
}

/* --- Settings & Preferences --- */

.pref-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.pref-item:last-child {
    border-bottom: none;
}

.pref-label {
    font-weight: 500;
    color: #334155;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color, #5D5FEF);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Danger Zone */
.danger-zone {
    margin-top: 2rem;
    border: 1px solid #fca5a5;
    background: #fef2f2;
    border-radius: 8px;
    padding: 1.5rem;
}

.danger-zone-header {
    color: #ef4444;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.danger-zone-text {
    color: #7f1d1d;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.danger-actions {
    display: flex;
    gap: 1rem;
}

.danger-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.delete-btn {
    background: #ef4444;
    color: white;
}

.delete-btn:hover {
    background: #dc2626;
}

.logout-btn {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.logout-btn:hover {
    background: #f1f5f9;
}

/* --- Dark Mode Layout Overrides --- */

[data-theme="dark"] .profile-header,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .tabs-container,
[data-theme="dark"] .profile-section {
    background: #1e293b; /* Dark card background */
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .profile-name {
    color: #f1f5f9;
}

[data-theme="dark"] .profile-username,
[data-theme="dark"] .profile-meta,
[data-theme="dark"] .stat-label {
    color: #94a3b8;
}

[data-theme="dark"] .tab-buttons {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .tab-button {
    color: #94a3b8;
}

[data-theme="dark"] .tab-button:hover {
    background: #1e293b;
    color: #f1f5f9;
}

[data-theme="dark"] .tab-button.active {
    background: #1e293b;
    color: var(--primary-color, #5D5FEF);
    border-bottom-color: var(--primary-color, #5D5FEF);
}

[data-theme="dark"] .section-header {
    border-color: #334155;
}

[data-theme="dark"] .section-title {
    color: #f1f5f9;
}

[data-theme="dark"] .form-label {
    color: #cbd5e1;
}

[data-theme="dark"] .form-control input,
[data-theme="dark"] .form-control select {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .form-value {
    color: #e2e8f0;
}

[data-theme="dark"] .pref-item {
    border-color: #334155;
}

[data-theme="dark"] .pref-label {
    color: #e2e8f0;
}

[data-theme="dark"] .danger-zone {
    background: rgba(127, 29, 29, 0.2);
    border-color: #7f1d1d;
}

[data-theme="dark"] .danger-zone-text {
    color: #fca5a5;
}

[data-theme="dark"] .logout-btn {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .logout-btn:hover {
    background: #1e293b;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    .profile-avatar {
        margin-right: 0;
        margin-bottom: 1rem;
    }
    .profile-meta {
        justify-content: center;
        flex-wrap: wrap;
    }
    .tabs-container {
        border-radius: 0;
    }
    .tab-content {
        padding: 1.5rem 1rem;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Mobile Tab Improvements */
@media (max-width: 768px) {
    .tabs-container {
        border-radius: 12px;
        background: transparent;
        box-shadow: none;
    }

    .tab-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        background: transparent;
        border-bottom: none;
        padding: 0.5rem;
    }

    .tab-button {
        flex: 1 1 45%; /* 2 per row approx */
        text-align: center;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        border-radius: 8px;
        background: white;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        border-bottom: 1px solid #e2e8f0; /* Reset generic style */
        white-space: normal; /* Allow wrapping text if needed */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .tab-button.active {
        background: var(--primary-color, #5D5FEF);
        color: white;
        border-color: var(--primary-color, #5D5FEF);
        box-shadow: 0 2px 4px rgba(93, 95, 239, 0.3);
    }

    /* Dark mode adjustments for mobile tabs */
    [data-theme="dark"] .tab-button {
        background: #1e293b;
        border-color: #334155;
        color: #94a3b8;
    }

    [data-theme="dark"] .tab-button.active {
        background: var(--primary-color, #5D5FEF);
        color: white;
        border-color: var(--primary-color, #5D5FEF);
    }
}

/* Achievement Card States */
.achievement-card.locked {
    filter: grayscale(100%);
    opacity: 0.6;
    background-color: #f8fafc;
}

.achievement-card.unlocked {
    border-color: var(--primary-color, #5D5FEF);
    box-shadow: 0 4px 6px rgba(93, 95, 239, 0.1);
}

.achievement-card.unlocked .achievement-icon {
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

[data-theme="dark"] .achievement-card.locked {
    background-color: #1e293b;
    border-color: #334155;
    opacity: 0.5;
}

/* Chart Modal Styles */
.chart-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
    animation: fadeInModal 0.3s;
}

.chart-modal.open {
    display: flex;
}

.chart-modal-content {
    background-color: #fff;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    border-radius: 12px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-modal-title {
    margin: 0;
    font-size: 1.5rem;
    color: #1e293b;
}

.chart-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 10;
}

.chart-modal-close:hover,
.chart-modal-close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.chart-modal-body {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

[data-theme="dark"] .chart-modal-content {
    background-color: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .chart-modal-title {
    color: #f1f5f9;
}

[data-theme="dark"] .chart-modal-close {
    color: #cbd5e1;
}

[data-theme="dark"] .chart-modal-close:hover {
    color: #fff;
}

/* Force modal display when open class is present */
.modal.open {
    display: flex !important;
    justify-content: center;
    align-items: center;
}
