/* ==========================================================================
   TREINO APP - MOBILE FIRST DARK STYLING
   ========================================================================== */

:root {
    --bg-main: #080c14;
    --bg-card: #131b2e;
    --bg-card-hover: #19233c;
    --bg-input: #1a233b;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(56, 189, 248, 0.4);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    --accent-cyan: #38bdf8;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition-fast: 0.18s ease;
    --transition-smooth: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-stack);
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body.treino-app-body {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    padding-bottom: clamp(5.5rem, 5rem + 3vw, 7rem); /* Safe space for timer */
}

/* App Container */
.treino-app-container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(8, 12, 20, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-color);
    margin: 0 calc(-1 * clamp(0.75rem, 0.5rem + 1vw, 1.25rem)) 0.75rem;
    padding: clamp(0.6rem, 0.4rem + 1vw, 0.9rem) clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 640px;
    margin: 0 auto;
}

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

.brand-icon {
    font-size: clamp(1.2rem, 1rem + 1vw, 1.5rem);
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.5));
}

.brand-text {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.brand-title {
    font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 40%, var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.today-badge {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--accent-emerald);
    background: var(--accent-emerald-glow);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:active {
    transform: scale(0.92);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ==========================================================================
   TABS NAVIGATION (HORIZONTAL PILLS)
   ========================================================================== */
.workout-tabs-container {
    position: sticky;
    top: clamp(3.2rem, 2.8rem + 1vw, 3.8rem);
    z-index: 35;
    background: var(--bg-main);
    padding: 0.4rem 0 0.8rem;
    margin-bottom: 0.5rem;
}

.tabs-nav {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0.2rem;
}

.tabs-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: clamp(0.55rem, 0.45rem + 0.4vw, 0.75rem) clamp(0.9rem, 0.75rem + 0.6vw, 1.25rem);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn.active {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-color: var(--accent-cyan);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.22);
}

.tab-btn:active {
    transform: scale(0.96);
}

/* ==========================================================================
   WORKOUT PANELS
   ========================================================================== */
.tab-panel {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

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

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

.panel-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    padding: 0 0.25rem;
}

.panel-title {
    font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.panel-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.panel-counter {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
}

/* ==========================================================================
   EXERCISE CARDS
   ========================================================================== */
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 0.6rem + 0.4vw, 1rem);
}

.exercise-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: clamp(0.85rem, 0.75rem + 0.5vw, 1.15rem);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.exercise-card.completed {
    border-color: rgba(16, 185, 129, 0.35);
    background: linear-gradient(180deg, #131b2e 0%, rgba(16, 185, 129, 0.05) 100%);
}

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

.card-title-group {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex: 1;
    min-width: 0;
}

.card-index {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.card-title {
    font-size: clamp(0.98rem, 0.92rem + 0.3vw, 1.15rem);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card Preview Button (Opens Modal) */
.btn-card-preview {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    color: var(--accent-cyan);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.btn-card-preview:active {
    background: rgba(56, 189, 248, 0.15);
    transform: scale(0.95);
}

/* Specs Bar */
.card-specs {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.9fr;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.spec-item {
    display: flex;
    flex-direction: column;
}

.spec-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.spec-value {
    font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spec-carga .spec-value {
    color: var(--accent-cyan);
    font-weight: 800;
}

.spec-rest {
    cursor: pointer;
}
.spec-rest .spec-value {
    color: var(--accent-amber);
}

/* Note snippet */
.card-note-snippet {
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: rgba(245, 158, 11, 0.06);
    border-left: 2px solid var(--accent-amber);
    padding: 0.35rem 0.6rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 0.75rem;
    line-height: 1.35;
}

/* ==========================================================================
   INTERACTIVE SETS TRACKER (BUBBLES)
   ========================================================================== */
.card-sets-tracker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.2rem;
}

.sets-tracker-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sets-bubbles {
    display: flex;
    gap: clamp(0.45rem, 0.35rem + 0.4vw, 0.75rem);
    flex-wrap: wrap;
}

.set-bubble {
    width: clamp(38px, 34px + 1vw, 44px);
    height: clamp(38px, 34px + 1vw, 44px);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition-fast);
}

.set-bubble .set-check-icon {
    display: none;
}

.set-bubble:active {
    transform: scale(0.9);
}

.set-bubble.done {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: #ffffff;
    box-shadow: 0 0 12px var(--accent-emerald-glow);
}

.set-bubble.done .set-num {
    display: none;
}

.set-bubble.done .set-check-icon {
    display: block;
    stroke: #ffffff;
}

/* ==========================================================================
   REST TIMER WIDGET (FLOATING BOTTOM)
   ========================================================================== */
.rest-timer-widget {
    position: fixed;
    bottom: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    left: 50%;
    transform: translateX(-50%) translateY(140%);
    width: calc(100% - clamp(1.5rem, 1rem + 2vw, 2.5rem));
    max-width: 480px;
    z-index: 100;
    background: rgba(19, 27, 46, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: var(--radius-full);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(245, 158, 11, 0.2);
    padding: 0.45rem 0.75rem;
    transition: transform var(--transition-smooth);
}

.rest-timer-widget.visible {
    transform: translateX(-50%) translateY(0);
}

.timer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.timer-progress-ring {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.timer-progress-ring svg {
    transform: rotate(-90deg);
}

.timer-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3.5;
}

.timer-circle-bar {
    fill: none;
    stroke: var(--accent-amber);
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-dasharray: 125.6; /* 2 * PI * 20 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.9s linear;
}

.timer-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
}

.timer-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.timer-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.timer-countdown {
    font-size: clamp(1.2rem, 1.1rem + 0.4vw, 1.4rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #ffffff;
    line-height: 1.1;
}

.timer-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-timer-adj {
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-timer-adj:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.92);
}

.btn-timer-stop {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--accent-rose);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-timer-stop:active {
    background: var(--accent-rose);
    color: #ffffff;
    transform: scale(0.9);
}

/* ==========================================================================
   MODAL BOTTOM-SHEET (EXERCISE EXECUTION & MEDIA)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-sheet {
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    border-radius: clamp(20px, 16px + 1vw, 26px) clamp(20px, 16px + 1vw, 26px) 0 0;
    padding: clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform var(--transition-smooth);
}

.modal-backdrop.open .modal-sheet {
    transform: translateY(0);
}

.modal-handle-bar {
    display: flex;
    justify-content: center;
    padding-bottom: 0.6rem;
}

.modal-handle {
    width: 44px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
}

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

.modal-tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.15rem;
}

.modal-title {
    font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.35rem);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.25;
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.modal-close-btn:active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Modal Media (GIF / Image / Video) */
.modal-media-wrap {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000000;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.modal-media-wrap img {
    display: block;
    width: 100%;
    max-height: 380px;
    object-fit: contain;
    background: #000;
}

.modal-media-wrap video {
    display: block;
    width: 100%;
    max-height: 380px;
    object-fit: contain;
    background: #000;
}

.modal-media-wrap iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16/9;
    border: none;
}

/* Modal Stats Row */
.modal-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-pill {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
}

.stat-pill-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.15rem;
}

.stat-pill-val {
    font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
    color: var(--accent-cyan);
    font-weight: 800;
}

/* Modal Notes */
.modal-notes-wrap {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.5rem;
}

.notes-heading {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-amber);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-notes-text {
    font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-line;
}

/* Empty State */
.empty-state-card {
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: clamp(2rem, 1.5rem + 2vw, 3.5rem) clamp(1rem, 0.8rem + 1vw, 2rem);
    margin-top: 1.5rem;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state-card h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.empty-state-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}
