/**
 * Reusable UI Components
 * Toast notifications, spinners, overlays, etc.
 */

/* ==================== Toast Notifications ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 500px;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    font-size: 0.938rem;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

/* Toast variants */
.toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

/* Dark mode toast */
.dark-mode .toast {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.dark-mode .toast-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.dark-mode .toast-error {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

/* Mobile toast adjustments */
@media (max-width: 768px) {
    .toast {
        left: 20px;
        right: 20px;
        min-width: unset;
        max-width: unset;
    }
}

/* ==================== Spinner / Loading ==================== */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

.spinner-sm {
    width: 0.75rem;
    height: 0.75rem;
    border-width: 1.5px;
}

/* Button loading state */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading .spinner {
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* ==================== Loading Overlay ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
}

.loading-spinner {
    background: var(--card-bg);
    padding: 2rem 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.loading-spinner .spinner {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
    border-color: rgba(59, 130, 246, 0.3);
    border-top-color: var(--primary);
    margin: 0 auto 1rem;
}

.loading-text {
    color: var(--text-primary);
    font-weight: 500;
    margin-top: 1rem;
}

/* ==================== Confirm Dialog ==================== */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.confirm-overlay.show {
    opacity: 1;
}

.confirm-dialog {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirm-message {
    color: var(--text-primary);
    font-size: 1.063rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.confirm-actions .btn {
    flex: 1;
}

/* ==================== Form Validation ==================== */
.field-error {
    color: var(--danger);
    font-size: 0.813rem;
    margin-top: 0.25rem;
    display: none;
}

input.invalid,
textarea.invalid,
select.invalid {
    border-color: var(--danger);
}

input.valid,
textarea.valid,
select.valid {
    border-color: var(--success);
}

input.invalid:focus,
textarea.invalid:focus,
select.invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

input.valid:focus,
textarea.valid:focus,
select.valid:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Password strength indicator */
.password-strength {
    margin-top: 0.5rem;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 2px;
}

.password-strength-bar.weak {
    width: 33%;
    background: var(--danger);
}

.password-strength-bar.fair {
    width: 66%;
    background: var(--warning);
}

.password-strength-bar.good {
    width: 85%;
    background: #10b981;
}

.password-strength-bar.strong {
    width: 100%;
    background: var(--success);
}

.password-strength-text {
    font-size: 0.813rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.password-strength-text.weak { color: var(--danger); }
.password-strength-text.fair { color: var(--warning); }
.password-strength-text.good { color: #10b981; }
.password-strength-text.strong { color: var(--success); }

/* ==================== Empty States ==================== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: 0.938rem;
    margin-bottom: 1.5rem;
}

/* ==================== Progress Bar ==================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar-animated .progress-bar-fill {
    background: linear-gradient(
        90deg,
        var(--primary) 0%,
        var(--primary-hover) 50%,
        var(--primary) 100%
    );
    background-size: 200% 100%;
    animation: progressShine 2s linear infinite;
}

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

/* ==================== Skeleton Loaders ==================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--border-light) 25%,
        var(--background) 50%,
        var(--border-light) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: var(--radius-sm);
}

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

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

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

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-md);
}

/* ==================== Badges ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 0.375rem;
}

/* Badge variants */
.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #f1f5f9;
    color: #475569;
}

/* Dark mode badges */
.dark-mode .badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.dark-mode .badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.dark-mode .badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.dark-mode .badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

/* ==================== Tooltips ==================== */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 0.5rem 0.75rem;
    background: var(--text-primary);
    color: var(--card-bg);
    font-size: 0.813rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ==================== Utility Classes ==================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden { display: none; }
.visible { display: block; }

/* ==================== Responsive Utilities ==================== */
@media (max-width: 768px) {
    .hide-mobile { display: none; }
    .show-mobile { display: block; }
}

@media (min-width: 769px) {
    .hide-desktop { display: none; }
    .show-desktop { display: block; }
}
