/* ==========================================================================
   FitTrack Pro - UI Components (Buttons, Controls, Cards, Modals, Badges)
   ========================================================================== */

/* UI Cards System */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-hover);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 0;
}

.stat-info {
    min-width: 0;
    flex: 1;
}

.stat-card .icon {
    font-size: 1.5rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.stat-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    outline: none;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
    background: var(--danger-gradient);
    color: #ffffff;
}

.btn-success {
    background: var(--success-gradient);
    color: #ffffff;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.badge-primary { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fde68a; }

/* Item Grids & Cards */
.workouts-list, .exercises-grid, .routines-grid, .challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.workout-card, .exercise-item, .routine-item, .challenge-item {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.workout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.workout-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.category-tag {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Component Overrides for Mobile Portrait (< 600px) */
@media (max-width: 600px) {
    .stat-card {
        padding: 0.85rem !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .stat-card .icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.1rem !important;
        flex-shrink: 0 !important;
    }

    .stat-info {
        min-width: 0 !important;
        flex: 1 !important;
    }

    .stat-info h3 {
        font-size: 1.15rem !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .stat-info .btn,
    .stat-card .btn {
        max-width: 100% !important;
        white-space: normal !important;
        word-break: break-word !important;
        box-sizing: border-box !important;
    }

    .modal-content {
        width: 94vw !important;
        max-width: 94vw !important;
        max-height: 90vh !important;
        margin: auto !important;
        padding: 1.1rem !important;
        border-radius: var(--radius-lg) !important;
    }

    .modal-content input.form-control,
    .modal-content select.form-control,
    .modal-content textarea.form-control {
        font-size: 16px !important;
    }
}

/* Compact & Subtle Mobile Portrait Buttons (< 768px) */
@media (max-width: 768px) {
    .btn {
        padding: 0.55rem 1rem !important;
        font-size: 0.88rem !important;
    }

    .btn-sm,
    .btn-share-workout,
    .edit-workout-btn,
    .delete-workout-btn,
    .share-workout-btn,
    .dash-share-btn {
        padding: 0.35rem 0.65rem !important;
        font-size: 0.78rem !important;
        font-weight: 500 !important;
        gap: 0.3rem !important;
        border-radius: var(--radius-sm) !important;
    }

    /* Subtle Glassmorphic Styling for Small Action Buttons */
    .btn-secondary.btn-sm,
    .edit-workout-btn {
        background: rgba(255, 255, 255, 0.05) !important;
        color: var(--text-muted) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: none !important;
    }

    .btn-secondary.btn-sm:hover,
    .btn-secondary.btn-sm:active,
    .edit-workout-btn:hover,
    .edit-workout-btn:active {
        background: rgba(255, 255, 255, 0.12) !important;
        color: var(--text-main) !important;
    }

    .btn-danger.btn-sm,
    .delete-workout-btn {
        background: rgba(239, 68, 68, 0.12) !important;
        color: #f87171 !important;
        border: 1px solid rgba(239, 68, 68, 0.25) !important;
        box-shadow: none !important;
    }

    .btn-danger.btn-sm:hover,
    .btn-danger.btn-sm:active,
    .delete-workout-btn:hover,
    .delete-workout-btn:active {
        background: rgba(239, 68, 68, 0.25) !important;
        color: #ffffff !important;
        border-color: rgba(239, 68, 68, 0.4) !important;
    }

    .btn-share-workout,
    .share-workout-btn,
    .dash-share-btn {
        background: rgba(139, 92, 246, 0.1) !important;
        color: #a78bfa !important;
        border: 1px solid rgba(139, 92, 246, 0.2) !important;
        box-shadow: none !important;
    }

    .btn-share-workout:hover,
    .btn-share-workout:active,
    .share-workout-btn:hover,
    .share-workout-btn:active,
    .dash-share-btn:hover,
    .dash-share-btn:active {
        background: rgba(139, 92, 246, 0.22) !important;
        color: #c4b5fd !important;
    }
}
