/**
 * Component Styles
 * Author: datvd
 * Created: 2026-01-23
 */

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn-icon {
    padding: var(--space-3);
}

.btn-full {
    width: 100%;
}

/* ==================== Cards ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-color-light);
    box-shadow: var(--shadow-lg);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    transform: translateY(-2px);
}

.card-image {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--bg-surface);
}

.card-body {
    padding: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ==================== Badges ==================== */
.badge {
    display: inline-flex;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.badge-primary {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
}

.badge-success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
}

.badge-error {
    background: rgba(244, 67, 54, 0.2);
    color: var(--error);
}

/* Muscle badges */
.badge-chest {
    background: rgba(233, 30, 99, 0.2);
    color: var(--muscle-chest);
}

.badge-back {
    background: rgba(156, 39, 176, 0.2);
    color: var(--muscle-back);
}

.badge-shoulders {
    background: rgba(63, 81, 181, 0.2);
    color: var(--muscle-shoulders);
}

.badge-biceps {
    background: rgba(0, 188, 212, 0.2);
    color: var(--muscle-biceps);
}

.badge-triceps {
    background: rgba(0, 150, 136, 0.2);
    color: var(--muscle-triceps);
}

.badge-legs {
    background: rgba(139, 195, 74, 0.2);
    color: var(--muscle-legs);
}

.badge-core {
    background: rgba(255, 152, 0, 0.2);
    color: var(--muscle-core);
}

/* Difficulty */
.badge-beginner {
    background: rgba(76, 175, 80, 0.2);
    color: var(--difficulty-beginner);
}

.badge-intermediate {
    background: rgba(255, 193, 7, 0.2);
    color: var(--difficulty-intermediate);
}

.badge-advanced {
    background: rgba(244, 67, 54, 0.2);
    color: var(--difficulty-advanced);
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* ==================== Tabs ==================== */
.tabs {
    display: flex;
    gap: var(--space-1);
    background: var(--bg-surface);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.tab {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* ==================== Tags ==================== */
.tag {
    display: inline-flex;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tag:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tag.active {
    background: var(--primary);
    color: white;
}

/* ==================== Avatar ==================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
    color: var(--primary);
    overflow: hidden;
}

.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-lg {
    width: 56px;
    height: 56px;
}

.avatar-xl {
    width: 80px;
    height: 80px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==================== Progress ==================== */
.progress {
    height: 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ==================== Modal ==================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: calc(100% - 32px);
    max-width: 500px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    padding: var(--space-5);
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-4);
    border-top: 1px solid var(--border-color);
}

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: var(--header-height);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

@media (max-width: 767px) {
    .toast-container {
        top: var(--space-4);
        right: var(--space-4);
        left: auto;
        transform: none;
        width: auto;
        max-width: 300px;
    }
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
    min-width: 200px;
}

.toast-message {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error .toast-icon {
    color: var(--error);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info .toast-icon {
    color: var(--info);
}

.toast-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== Favorite Button ==================== */
.btn-favorite {
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.btn-favorite:hover {
    color: var(--error);
    transform: scale(1.1);
}

.btn-favorite.active {
    color: var(--error);
}

.btn-favorite.active svg {
    fill: currentColor;
}

/* ==================== Empty State ==================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
}

/* ==================== Custom Select Dropdown ==================== */
.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select-trigger {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.custom-select-trigger:hover {
    border-color: var(--primary);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-dropdown);
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.custom-select.open .custom-select-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
}

.custom-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.custom-option.selected {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    font-weight: var(--font-medium);
}

/* ==================== Utilities & Helpers ==================== */
.bg-glass {
    background: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

[data-theme="light"] .bg-glass {
    background: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.border-dashed {
    border-style: dashed !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.list-unstyled {
    list-style: none;
    padding-left: 0;
}

.space-y-2>*+* {
    margin-top: var(--space-2);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

.gap-3 {
    gap: var(--space-3);
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.text-center {
    text-align: center;
}

.font-bold {
    font-weight: var(--font-bold);
}

.p-8 {
    padding: var(--space-8) !important;
}

.mt-4 {
    margin-top: var(--space-4) !important;
}

.mb-4 {
    margin-bottom: var(--space-4) !important;
}

.mb-6 {
    margin-bottom: var(--space-6) !important;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: var(--space-2);
}

.flex-1 {
    flex: 1;
}