/* ===== CSS Variables ===== */
:root {
    --bg-primary: #1A1A2E;
    --bg-secondary: #16213E;
    --bg-tertiary: #0F3460;
    --accent: #E94560;
    --accent-light: rgba(233, 69, 96, 0.2);
    --accent-shadow: rgba(233, 69, 96, 0.4);
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --text-muted: #666666;
    --success: #4CAF50;
    --danger: #F44336;
    --border-radius: 12px;
    --transition: all 0.2s ease;
}

/* ===== Theme: Green (Emerald) ===== */
[data-theme="green"] {
    --accent: #10B981;
    --accent-light: rgba(16, 185, 129, 0.2);
    --accent-shadow: rgba(16, 185, 129, 0.4);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

#app {
    height: 100%;
    position: relative;
}

/* ===== Screens ===== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: var(--bg-primary);
}

.screen.active {
    display: flex;
}

/* ===== Profile Selection ===== */
.profile-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #FF6B6B);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.profiles {
    display: flex;
    gap: 24px;
}

.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 32px;
    background: var(--bg-secondary);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.profile-card:hover,
.profile-card:active {
    border-color: var(--accent);
    transform: scale(1.02);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--accent);
}

.profile-avatar .material-icons-round {
    font-size: 40px;
    color: var(--accent);
}

.profile-name {
    font-weight: 600;
    font-size: 1.1rem;
}

/* ===== Login Form ===== */
.login-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 300px;
}

.login-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--accent);
    margin-bottom: 16px;
    overflow: hidden;
}

.login-avatar .material-icons-round {
    font-size: 50px;
    color: var(--accent);
}

.login-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.login-form h2 {
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.btn-text {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    min-height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--accent);
    cursor: pointer;
    overflow: hidden;
}

.header-avatar .material-icons-round {
    font-size: 20px;
    color: var(--accent);
}

.header-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover,
.icon-btn:active {
    background: var(--bg-tertiary);
}

.icon-btn .material-icons-round {
    font-size: 24px;
}

/* ===== Content ===== */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 80px;
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
    display: flex;
    background: var(--bg-secondary);
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item.active {
    color: var(--accent);
}

.nav-item .material-icons-round {
    font-size: 24px;
}

.nav-item span:last-child {
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.card:active {
    transform: scale(0.98);
    background: var(--bg-tertiary);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon .material-icons-round {
    font-size: 28px;
    color: var(--accent);
}

.card-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.card-arrow {
    color: var(--accent);
    font-size: 20px !important;
}

/* ===== Chips ===== */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.chip-accent {
    background: var(--accent-light);
    color: var(--accent);
}

.chip-success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
}

/* ===== Floating Action Button ===== */
.fab {
    position: fixed;
    bottom: 80px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--accent-shadow);
    transition: var(--transition);
    z-index: 50;
}

.fab:active {
    transform: scale(0.95);
}

.fab .material-icons-round {
    font-size: 20px;
}

/* Secondary FAB (discrete) */
.fab-secondary {
    position: fixed;
    bottom: 20px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    z-index: 49;
}

.fab-secondary:hover,
.fab-secondary:active {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}

.fab-secondary .material-icons-round {
    font-size: 18px;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state .material-icons-round {
    font-size: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Settings ===== */
.settings-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.settings-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0 40px;
}

.settings-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--accent);
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.settings-avatar .material-icons-round {
    font-size: 50px;
    color: var(--accent);
}

.avatar-edit-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 0;
    display: flex;
    justify-content: center;
}

.avatar-edit-overlay .material-icons-round {
    font-size: 18px;
    color: white;
}

.settings-list {
    width: 100%;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    margin-bottom: 12px;
    transition: var(--transition);
    text-align: left;
}

.settings-item:active {
    background: var(--bg-tertiary);
}

.settings-item>.material-icons-round:first-child {
    color: var(--accent);
}

.settings-item.danger>.material-icons-round:first-child,
.settings-item.danger .settings-item-title {
    color: var(--danger);
}

.settings-item-text {
    flex: 1;
}

.settings-item-title {
    font-weight: 500;
}

.settings-item-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.settings-item>.material-icons-round:last-child {
    color: var(--text-muted);
}

.app-version {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 40px;
}

/* ===== Toggle Switch ===== */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    transition: var(--transition);
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle input:checked+.toggle-slider {
    background: var(--accent);
}

.toggle input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

/* ===== Color Picker ===== */
.color-picker {
    display: flex;
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: white;
}

.color-option.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: bold;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.form-input:focus {
    box-shadow: 0 0 0 2px var(--accent);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23B0B0B0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    width: 100%;
    max-width: 500px;
    background: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-header .material-icons-round {
    color: var(--accent);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    margin-left: auto;
}

/* ===== Buttons ===== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:active {
    background: #D03050;
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Search ===== */
.search-container {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.search-input:focus {
    box-shadow: 0 0 0 2px var(--accent);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ===== Filters ===== */
.filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip.active {
    background: var(--accent);
    color: white;
}

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== Chart ===== */
.chart-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 12px;
}

.chart-canvas {
    width: 100%;
    height: 180px;
}

/* ===== Level Cards (Escalier) ===== */
.level-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.level-card {
    width: calc(33.33% - 8px);
    min-width: 90px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.level-card:active,
.level-card.active {
    border-color: var(--accent);
}

.level-card-title {
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.level-card-sessions {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.level-card-max {
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ===== Performance List ===== */
.perf-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 12px;
}

.perf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.perf-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.perf-date .material-icons-round {
    font-size: 16px;
    color: var(--accent);
}

.perf-badge {
    padding: 4px 10px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.perf-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.perf-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 0.85rem;
}

.perf-stat .material-icons-round {
    font-size: 14px;
    color: var(--accent);
}

/* ===== Sets Display ===== */
.sets-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.set-item {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 0.85rem;
}

.set-number {
    color: var(--accent);
    font-weight: 600;
}

/* ===== Loading ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Section Headers ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-title {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
}

.section-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Card Menu Button ===== */
.card-menu-btn,
.perf-menu-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.card-menu-btn:hover,
.card-menu-btn:active,
.perf-menu-btn:hover,
.perf-menu-btn:active {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.perf-menu-btn {
    width: 32px;
    height: 32px;
}

.perf-menu-btn .material-icons-round {
    font-size: 18px;
}

/* ===== Stat Card with Icon ===== */
.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.stat-icon .material-icons-round {
    font-size: 20px;
    color: var(--accent);
}

/* ===== Action Menu ===== */
.action-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    padding: 12px 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 1001;
    animation: slideUp 0.2s ease;
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
}

.action-menu-item:active {
    background: var(--bg-tertiary);
}

.action-menu-item .material-icons-round {
    color: var(--accent);
}

.action-menu-item.danger .material-icons-round,
.action-menu-item.danger {
    color: var(--danger);
}

/* ===== Level Card Clickable ===== */
.level-card {
    cursor: pointer;
    transition: var(--transition);
}

.level-card:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}