/* ========================================
   Osy Treino – Sistema de Treinos Desktop
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');

/* ── Variáveis ═══════════════════════════ */
:root {
    --primary: #a238ff;
    --primary-hover: #8a1fe6;
    --primary-light: #f3e8ff;
    --accent-green: #00B67A;
    --accent-red: #E53935;
    --accent-orange: #FF9800;
    --accent-purple: #7C4DFF;

    --bg: #F4F6F9;
    --surface: #FFFFFF;
    --sidebar-bg: #1A1D23;
    --sidebar-hover: #2A2D35;
    --sidebar-active: #a238ff;
    --sidebar-text: #9CA3AF;
    --sidebar-text-active: #FFFFFF;

    --text: #1A1A2E;
    --text-secondary: #6B7280;
    --text-hint: #9CA3AF;
    --border: #E5E7EB;
    --divider: #F0F0F0;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

    --radius: 8px;
    --radius-lg: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

/* ── Reset ═══════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout Principal ════════════════════ */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ── Sidebar ═════════════════════════════ */
.sidebar {
    width: 250px;
    min-width: 250px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand .brand-icon .material-icons-round {
    color: #fff;
    font-size: 22px;
}

.sidebar-brand .brand-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.sidebar-brand .brand-sub {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    padding: 12px 12px 6px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--sidebar-text);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    text-align: left;
}

.nav-btn:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-btn.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.nav-btn .material-icons-round {
    font-size: 20px;
}

/* ── Área Principal ══════════════════════ */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Top Bar ═════════════════════════════ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

/* ── Conteúdo ════════════════════════════ */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ── Página oculta ═══════════════════════ */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ── Botões ══════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}

.btn-danger:hover {
    background: #C62828;
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
}

.btn-success:hover {
    background: #009960;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.btn-icon {
    padding: 7px;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-icon .material-icons-round {
    font-size: 18px;
}

.btn-play {
    padding: 6px 10px;
    border-radius: var(--radius);
    background: var(--accent-green);
    border: none;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    transition: background var(--transition);
}

.btn-play:hover {
    background: #009960;
}

.btn-play .material-icons-round {
    font-size: 16px;
}

/* ── Cards / Painéis ═════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider);
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.card-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.card-body {
    padding: 20px;
}

/* ── Tabelas ═════════════════════════════ */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

table tbody td {
    padding: 12px 14px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--divider);
    vertical-align: middle;
}

table tbody tr:hover {
    background: var(--primary-light);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Formulários ═════════════════════════ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

.form-group input::placeholder {
    color: var(--text-hint);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ── Checkbox de dias ════════════════════ */
.days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.day-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.82rem;
    font-weight: 500;
    user-select: none;
}

.day-check:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.day-check input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.day-check.checked {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* ── Tabs de Treino (A–F) ════════════════ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* ── Badges ══════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
}

.badge-blue {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-green {
    background: #E8F5E9;
    color: var(--accent-green);
}

.badge-orange {
    background: #FFF3E0;
    color: var(--accent-orange);
}

.badge-purple {
    background: #EDE7F6;
    color: var(--accent-purple);
}

/* ── Empty State ═════════════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-hint);
}

.empty-state .material-icons-round {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ── Modal ════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--divider);
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 6px;
    transition: background var(--transition);
}

.modal-close:hover {
    background: var(--bg);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--divider);
}

/* ── Actions na tabela ═══════════════════ */
.actions-cell {
    display: flex;
    gap: 6px;
}

/* ── Treino row inline ═══════════════════ */
.treino-row select,
.treino-row input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.82rem;
    color: var(--text);
    background: var(--surface);
    outline: none;
}

.treino-row select {
    min-width: 120px;
}

.treino-row input {
    width: 80px;
}

.treino-row select:focus,
.treino-row input:focus {
    border-color: var(--primary);
}

/* ── Stats cards ═════════════════════════ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon .material-icons-round {
    font-size: 24px;
    color: #fff;
}

.stat-icon.blue {
    background: var(--primary);
}

.stat-icon.green {
    background: var(--accent-green);
}

.stat-icon.orange {
    background: var(--accent-orange);
}

.stat-icon.purple {
    background: var(--accent-purple);
}

.stat-info .stat-val {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.stat-info .stat-lbl {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Toast ════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 600;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* ── Export options ═══════════════════════ */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.export-option input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

.export-option .export-label {
    font-weight: 600;
    font-size: 0.9rem;
}

.export-option .export-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Dia da semana badges na tabela ═══════ */
.day-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.day-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
}

/* ── Responsividade ══════════════════════ */
@media (max-width: 900px) {
    .sidebar {
        width: 60px;
        min-width: 60px;
    }

    .sidebar-brand .brand-name,
    .sidebar-brand .brand-sub,
    .nav-section-title,
    .nav-btn span:not(.material-icons-round) {
        display: none;
    }

    .nav-btn {
        justify-content: center;
        padding: 10px;
    }

    .sidebar-brand {
        justify-content: center;
        padding: 16px 8px;
    }

    .content {
        padding: 20px 16px;
    }

    .topbar {
        padding: 12px 16px;
    }
}

/* ── Anamnese ═══════════════════════════ */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.anamnese-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1A1D23 0%, #2A2D35 100%);
    border-radius: var(--radius) var(--radius) 0 0;
    color: #fff;
}

.anamnese-header-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.anamnese-header-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.anamnese-header-info p {
    font-size: 0.8rem;
    color: #9CA3AF;
    margin: 2px 0 0;
}

.anamnese-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.anamnese-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.anamnese-section-title .material-icons-round {
    font-size: 20px;
}

.anamnese-section-title.saude {
    border-left: 4px solid #E53935;
}

.anamnese-section-title.saude .material-icons-round {
    color: #E53935;
}

.anamnese-section-title.treino {
    border-left: 4px solid var(--primary);
}

.anamnese-section-title.treino .material-icons-round {
    color: var(--primary);
}

.anamnese-section-title.medidas {
    border-left: 4px solid #FF9800;
}

.anamnese-section-title.medidas .material-icons-round {
    color: #FF9800;
}

.anamnese-section-title.fotos {
    border-left: 4px solid #00B67A;
}

.anamnese-section-title.fotos .material-icons-round {
    color: #00B67A;
}

.anamnese-section-title.metas {
    border-left: 4px solid #2196F3;
}

.anamnese-section-title.metas .material-icons-round {
    color: #2196F3;
}

.anamnese-section-title.contato {
    border-left: 4px solid #7C4DFF;
}

.anamnese-section-title.contato .material-icons-round {
    color: #7C4DFF;
}

.anamnese-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0;
}

.anamnese-field {
    padding: 12px 20px;
    border-bottom: 1px solid var(--divider);
    border-right: 1px solid var(--divider);
}

.anamnese-field:last-child {
    border-bottom: none;
}

.anamnese-field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.anamnese-field-value {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.4;
    word-break: break-word;
}

.anamnese-field-value.empty {
    color: var(--text-hint);
    font-style: italic;
}

.anamnese-field.full-width {
    grid-column: 1 / -1;
    border-right: none;
}

.anamnese-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px 20px;
}

.anamnese-photo-card {
    text-align: center;
}

.anamnese-photo-card img {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.anamnese-photo-card img:hover {
    transform: scale(1.03);
    border-color: var(--primary);
}

.anamnese-photo-card p {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.anamnese-photo-card a {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
}

.anamnese-photo-card a:hover {
    text-decoration: underline;
}

.anamnese-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.anamnese-badge.sim {
    background: #FFEBEE;
    color: #C62828;
}

.anamnese-badge.nao {
    background: #E8F5E9;
    color: #2E7D32;
}