/* ==========================================================================
   NIFELUX TECHNOLOGIES - REUSABLE COMPONENTS
   ========================================================================== */

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid transparent;
    text-decoration: none;
    user-select: none;
}

.btn:disabled,
.btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--fs-xs);
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--fs-base);
}

.btn-xl {
    padding: 18px 36px;
    font-size: var(--fs-md);
}

.btn-primary {
    background: var(--color-accent);
    color: #ffffff;
    border-color: var(--color-accent);
    box-shadow: 0 4px 16px rgba(0, 168, 255, 0.25);
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    box-shadow: 0 6px 24px rgba(0, 168, 255, 0.4);
    transform: translateY(-2px);
    color: #ffffff;
}

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

.btn-outline {
    background: transparent;
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
}

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

.btn-success:hover {
    background: #0ea271;
    transform: translateY(-2px);
    color: #ffffff;
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    color: #ffffff;
}

/* Button loading state */
.btn.loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: buttonSpin 0.7s linear infinite;
}

@keyframes buttonSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ---------- FORM INPUTS ---------- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--fs-base);
    transition: all var(--transition-base);
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
    border-color: var(--color-border-hover);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-bg-tertiary);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

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

.form-input.error,
.form-textarea.error {
    border-color: var(--color-error);
    background: rgba(239, 68, 68, 0.05);
}

.form-error {
    color: var(--color-error);
    font-size: var(--fs-sm);
    margin-top: 4px;
}

.form-help {
    color: var(--color-text-subtle);
    font-size: var(--fs-xs);
    margin-top: 4px;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-base);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
}

.card-body {
    color: var(--color-text-secondary);
}

/* ---------- BADGES ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-info);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.15);
    color: var(--color-text-muted);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ---------- LOADING SKELETON ---------- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-secondary) 0%,
        var(--color-bg-tertiary) 50%,
        var(--color-bg-secondary) 100%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-image {
    aspect-ratio: 16/10;
    width: 100%;
    border-radius: var(--radius-md);
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: var(--radius-md);
}

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

/* ---------- TOAST NOTIFICATIONS ---------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(26, 35, 64, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    pointer-events: auto;
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    line-height: var(--lh-normal);
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-subtle);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    font-size: var(--fs-lg);
    line-height: 1;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--toast-accent-color, var(--color-accent));
    animation: toastProgress linear forwards;
}

/* Toast variants */
.toast.success {
    --toast-accent-color: var(--color-success);
    border-left: 3px solid var(--color-success);
}

.toast.success .toast-icon {
    background: var(--color-success);
    color: #fff;
}

.toast.error {
    --toast-accent-color: var(--color-error);
    border-left: 3px solid var(--color-error);
}

.toast.error .toast-icon {
    background: var(--color-error);
    color: #fff;
}

.toast.warning {
    --toast-accent-color: var(--color-warning);
    border-left: 3px solid var(--color-warning);
}

.toast.warning .toast-icon {
    background: var(--color-warning);
    color: #fff;
}

.toast.info {
    --toast-accent-color: var(--color-info);
    border-left: 3px solid var(--color-info);
}

.toast.info .toast-icon {
    background: var(--color-info);
    color: #fff;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ---------- MODAL ---------- */
.modal-container {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.modal-container.active {
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal-container.active .modal-overlay {
    opacity: 1;
}

.modal {
    position: relative;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all var(--transition-spring);
}

.modal-container.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.modal-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: var(--fs-xl);
}

.modal-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.modal-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.modal-icon.info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-info);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.modal-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.modal-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-semibold);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-subtle);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    font-size: var(--fs-xl);
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.modal-body {
    color: var(--color-text-secondary);
    line-height: var(--lh-relaxed);
    margin-bottom: var(--space-xl);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.modal-footer .btn {
    min-width: 100px;
}

/* ---------- PAGE LOADER ---------- */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--color-bg-primary);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-slow);
}

.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- UTILITIES ---------- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.hidden { display: none !important; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
