/* ===================================
   REUSABLE COMPONENTS
   =================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    user-select: none;
}

.btn:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
}

.btn-block {
    width: 100%;
}

/* Button Variants */
.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gradient-2);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-500);
    color: var(--primary-500);
}

.btn-icon {
    margin-left: var(--space-2);
    font-size: var(--text-lg);
    transition: transform var(--transition-fast);
}

.btn:hover .btn-icon {
    transform: translateX(4px);
}

/* Glass Card */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
}

[data-theme="dark"] .glass-card {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.1);
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* Cards */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: 0;
}

.card-body {
    margin-bottom: var(--space-4);
}

.card-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-color);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--neutral-100);
    color: var(--neutral-700);
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-orange);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    font-size: var(--text-lg);
    pointer-events: none;
}

.input-group .form-input {
    padding-left: var(--space-12);
}

.input-action {
    position: absolute;
    right: var(--space-4);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    font-size: var(--text-lg);
    transition: transform var(--transition-fast);
}

.input-action:hover {
    transform: scale(1.1);
}

.form-error {
    display: block;
    font-size: var(--text-sm);
    color: var(--accent-red);
    margin-top: var(--space-2);
}

.form-input.error {
    border-color: var(--accent-red);
}

.form-input.success {
    border-color: var(--accent-green);
}

/* Checkbox & Radio */
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
    display: none;
}

.checkbox-custom {
    position: relative;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: var(--text-sm);
}

.checkbox-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Loader */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: none;
    animation: fadeIn 0.3s ease;
}

.modal-backdrop.active {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 600px;
    width: 90%;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    z-index: var(--z-modal);
    display: none;
    animation: scaleIn 0.3s ease;
}

.modal.active {
    display: block;
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin: 0;
}

.modal-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: none;
    border: none;
    font-size: var(--text-2xl);
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Alert */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--primary-500);
    color: var(--primary-500);
}

/* Progress Bar */
.progress {
    width: 100%;
    height: 8px;
    background: var(--neutral-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-1);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--neutral-200) 25%,
        var(--neutral-100) 50%,
        var(--neutral-200) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: var(--space-4);
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-2) var(--space-3);
    background: var(--neutral-900);
    color: white;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-base);
    z-index: var(--z-tooltip);
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-8) 0;
}

.divider-text {
    display: flex;
    align-items: center;
    text-align: center;
    margin: var(--space-8) 0;
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider-text span {
    padding: 0 var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Gradient Backgrounds */
.gradient-bg-1 {
    background: var(--gradient-1);
}

.gradient-bg-2 {
    background: var(--gradient-2);
}

.gradient-bg-3 {
    background: var(--gradient-3);
}

.gradient-bg-4 {
    background: var(--gradient-4);
}

.gradient-bg-5 {
    background: var(--gradient-5);
}

.gradient-bg-6 {
    background: var(--gradient-6);
}