/* ==========================================================================
   Components - GymTracker Elite UI
   Reusable component classes built on design tokens
   ========================================================================== */

/* ==========================================================================
   Glass Morphism Cards
   ========================================================================== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.glass-card-elevated {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.glass-card-static {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-family: var(--font-primary);
    border-radius: var(--radius-lg);
    padding: 0 1.5rem;
    height: var(--btn-height-mobile);
    min-width: 2.75rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    font-size: 0.9375rem;
    line-height: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Primary (Cyan) */
.btn-primary {
    background: var(--color-cyan);
    color: var(--color-bg-primary);
    box-shadow: var(--shadow-cyan);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-cyan-dark);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.35);
}

/* Success (Green) */
.btn-success {
    background: var(--color-green);
    color: var(--color-bg-primary);
    box-shadow: var(--shadow-green);
}

.btn-success:hover:not(:disabled) {
    background: var(--color-green-dark);
    box-shadow: 0 6px 24px rgba(57, 255, 20, 0.35);
}

/* Secondary (Ghost card bg) */
.btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-card-hover);
    border-color: var(--color-cyan);
}

/* Danger (Red) */
.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--color-red);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
}

/* Small variant */
.btn-sm {
    height: var(--btn-height);
    padding: 0 1rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-md);
}

/* Icon-only button */
.btn-icon {
    width: var(--btn-height);
    height: var(--btn-height);
    padding: 0;
    border-radius: var(--radius-md);
}

/* ==========================================================================
   Form Inputs
   ========================================================================== */
.input {
    width: 100%;
    height: var(--input-height);
    padding: 0 1rem;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.input::placeholder {
    color: var(--color-text-disabled);
}

.input:focus {
    border-color: var(--color-cyan);
    box-shadow: 0 0 0 3px var(--color-cyan-glow);
}

.input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Workout-specific input (64px, JetBrains Mono, centered) */
.input-workout {
    width: 100%;
    height: var(--input-height-workout);
    padding: 0 0.5rem;
    background: var(--color-bg-input);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    -moz-appearance: textfield;
}

.input-workout::-webkit-inner-spin-button,
.input-workout::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-workout::placeholder {
    color: var(--color-text-disabled);
    font-size: 1rem;
}

.input-workout:focus {
    border-color: var(--color-cyan);
    box-shadow: 0 0 0 3px var(--color-cyan-glow);
}

/* Select */
.select {
    width: 100%;
    height: var(--input-height);
    padding: 0 2.5rem 0 1rem;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239CA3AF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

[dir="ltr"] .select {
    background-position: right 1rem center;
    padding: 0 1rem 0 2.5rem;
}

.select:focus {
    border-color: var(--color-cyan);
    box-shadow: 0 0 0 3px var(--color-cyan-glow);
}

/* Textarea */
.textarea {
    width: 100%;
    min-height: 6rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.textarea:focus {
    border-color: var(--color-cyan);
    box-shadow: 0 0 0 3px var(--color-cyan-glow);
}

/* Label */
.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.375rem;
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge-cyan {
    background: var(--color-cyan-glow);
    color: var(--color-cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.badge-green {
    background: var(--color-green-glow);
    color: var(--color-green);
    border: 1px solid rgba(57, 255, 20, 0.2);
}

.badge-purple {
    background: var(--color-purple-glow);
    color: var(--color-purple);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.badge-error {
    background: var(--color-red-glow);
    color: var(--color-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: var(--color-yellow-glow);
    color: var(--color-yellow);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-blue {
    background: var(--color-blue-glow);
    color: var(--color-blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-orange {
    background: var(--color-orange-glow);
    color: var(--color-orange);
    border: 1px solid rgba(249, 115, 22, 0.2);
}

/* ==========================================================================
   Stat Card
   ========================================================================== */
.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

/* ==========================================================================
   Table
   ========================================================================== */
.table-container {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container thead {
    background: rgba(255, 255, 255, 0.03);
}

.table-container th {
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    text-align: right;
}

[dir="ltr"] .table-container th {
    text-align: left;
}

.table-container td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    border-top: 1px solid var(--color-border);
}

.table-container tbody tr {
    transition: background-color var(--transition-fast);
}

.table-container tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   Modal System
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.modal-panel {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 28rem;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    position: relative;
    animation: scaleIn 0.25s ease-out;
}

.modal-panel-lg {
    max-width: 42rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.25rem;
}

[dir="ltr"] .modal-close {
    left: auto;
    right: 1rem;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    width: max-content;
    max-width: 90vw;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: all;
    animation: toastIn 0.3s ease-out;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
}

.toast.removing {
    animation: toastOut 0.3s ease-in forwards;
}

.toast-success {
    background: rgba(57, 255, 20, 0.12);
    border: 1px solid rgba(57, 255, 20, 0.3);
    color: var(--color-green);
}

.toast-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-red);
}

.toast-info {
    background: rgba(0, 212, 255, 0.12);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--color-cyan);
}

.toast-warning {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--color-yellow);
}

/* ==========================================================================
   Bottom Navigation
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg-dark);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: var(--z-fixed);
    padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 8px)) 0.5rem;
    min-height: var(--bottom-nav-height);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-lg);
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    min-width: 3.5rem;
}

.bottom-nav-item:hover {
    color: var(--color-text-secondary);
}

.bottom-nav-item.active {
    color: var(--color-cyan);
}

.bottom-nav-item svg,
.bottom-nav-item i {
    width: 1.375rem;
    height: 1.375rem;
}

/* ==========================================================================
   Increment Buttons (Workout)
   ========================================================================== */
.increment-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 2.75rem;
    padding: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.increment-btn:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-cyan);
    color: var(--color-cyan);
}

.increment-btn:active {
    transform: scale(0.93);
}

.increment-btn.inc-plus {
    border-color: rgba(57, 255, 20, 0.15);
    color: var(--color-green);
}

.increment-btn.inc-plus:hover {
    background: rgba(57, 255, 20, 0.08);
    border-color: rgba(57, 255, 20, 0.35);
}

.increment-btn.inc-minus {
    border-color: rgba(239, 68, 68, 0.15);
    color: var(--color-red);
}

.increment-btn.inc-minus:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.35);
}

.increment-grid {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
    width: 100%;
}

.input-group-workout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Previous set comparison badge */
.prev-set-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.12);
    color: var(--color-cyan);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.prev-set-hint:hover {
    background: rgba(0, 212, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.25);
}

.prev-set-hint .arrow-up {
    color: var(--color-green);
}

.prev-set-hint .arrow-down {
    color: var(--color-red);
}

/* ==========================================================================
   Pulse Dot (Status Indicator)
   ========================================================================== */
.pulse-dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    display: inline-block;
}

.pulse-dot::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: var(--radius-full);
    background: inherit;
    opacity: 0.4;
    animation: pulseDot 2s ease-in-out infinite;
}

.pulse-dot-green {
    background: var(--color-green);
}

.pulse-dot-cyan {
    background: var(--color-cyan);
}

.pulse-dot-red {
    background: var(--color-red);
}

.pulse-dot-yellow {
    background: var(--color-yellow);
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-card) 25%,
        var(--color-bg-card-hover) 50%,
        var(--color-bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
}

.skeleton-text-sm {
    height: 0.625rem;
    width: 60%;
}

.skeleton-circle {
    border-radius: var(--radius-full);
}

/* ==========================================================================
   Gradient Text
   ========================================================================== */
.gradient-text-cyan-green {
    background: linear-gradient(135deg, var(--color-cyan), var(--color-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-cyan-purple {
    background: linear-gradient(135deg, var(--color-cyan), var(--color-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */
.progress-bar {
    height: 0.5rem;
    background: var(--color-bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--color-cyan), var(--color-green));
    transition: width 0.5s ease;
}

/* ==========================================================================
   Gradient Border Card
   ========================================================================== */
.gradient-border-card {
    position: relative;
    background: var(--color-bg-card);
    border-radius: var(--radius-xl);
    padding: 2px;
    background: linear-gradient(135deg, var(--color-cyan), var(--color-purple));
}

.gradient-border-card-inner {
    background: var(--color-bg-card);
    border-radius: calc(var(--radius-xl) - 2px);
    padding: 1.5rem;
}

/* ==========================================================================
   Rest Timer (Workout)
   ========================================================================== */
.rest-timer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 20, 0.95);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.rest-timer-circle {
    width: 160px;
    height: 160px;
    border-radius: var(--radius-full);
    border: 4px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.rest-timer-circle svg {
    position: absolute;
    inset: -4px;
    transform: rotate(-90deg);
}

.rest-timer-value {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-cyan);
}

/* ==========================================================================
   Image Lightbox
   ========================================================================== */
.gym-img-clickable {
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}
.gym-img-clickable:hover {
    opacity: 0.85;
    transform: scale(1.03);
}

#gym-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    transition: background 0.3s, backdrop-filter 0.3s;
}
#gym-lightbox.active {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
}
#gym-lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 1rem;
    object-fit: contain;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.85);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
}
#gym-lightbox.active #gym-lightbox-img {
    transform: scale(1);
    opacity: 1;
}
#gym-lightbox-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    backdrop-filter: blur(8px);
    z-index: 1;
}
#gym-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}
