/* =========================================================
   widget.css — ابزارک‌های عمومی: search bar, chips, tooltip,
                 modal, dropdown, badge, skeleton, divider
   شهبازیون | SuFramework v3.0
   ========================================================= */

/* ─────────────────────────────────────────────────────────
   ۱. Search Bar (قابل استفاده در همه صفحات)
   ───────────────────────────────────────────────────────── */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.35rem 0.35rem 1.1rem;
    transition: var(--transition);
    max-width: 520px;
    width: 100%;
}

.search-box:focus-within {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.08);
}

.search-box input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.92rem;
    color: var(--c-text);
    padding: 0.55rem 0;
}

.search-box input::placeholder {
    color: var(--c-text-muted);
}

.search-box button {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: var(--c-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.search-box button:hover {
    background: var(--c-primary-dark);
    transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────
   ۲. Chips / Filter Chips
   ───────────────────────────────────────────────────────── */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--c-text-soft);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.chip:hover {
    border-color: var(--c-primary-light);
    color: var(--c-primary);
    background: var(--c-primary-soft);
}

.chip.is-active {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
}

.chip-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
}

.chip:not(.is-active) .chip-count {
    background: var(--c-bg-soft);
    color: var(--c-text-muted);
}

/* ─────────────────────────────────────────────────────────
   ۳. Badge
   ───────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-primary {
    background: var(--c-primary-soft);
    color: var(--c-primary-dark);
}

.badge-accent {
    background: #fef3c7;
    color: #92400e;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-muted {
    background: var(--c-bg-soft);
    color: var(--c-text-muted);
}

body.dark-mode .badge-primary {
    background: rgba(109, 40, 217, 0.25);
    color: #c4b5fd;
}

body.dark-mode .badge-accent {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

body.dark-mode .badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

body.dark-mode .badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* ─────────────────────────────────────────────────────────
   ۴. Dot / Status Indicator
   ───────────────────────────────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.status-dot.is-online  { background: var(--c-success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
.status-dot.is-offline { background: var(--c-text-muted); }
.status-dot.is-busy    { background: var(--c-danger);  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }
.status-dot.is-away    { background: var(--c-warning); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }

/* ─────────────────────────────────────────────────────────
   ۵. Tooltip
   ───────────────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--c-text);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    pointer-events: none;
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-3px);
}

/* ─────────────────────────────────────────────────────────
   ۶. Modal
   ───────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.is-open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--c-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: var(--transition);
    position: relative;
}

.modal.is-open .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--c-bg-alt);
    color: var(--c-text-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
    cursor: pointer;
}

.modal-close:hover {
    background: var(--c-danger);
    color: #fff;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 1.25rem;
    color: var(--c-text);
}

/* ─────────────────────────────────────────────────────────
   ۷. Dropdown
   ───────────────────────────────────────────────────────── */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.35rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: var(--transition);
    z-index: 500;
}

.dropdown.is-open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 0.55rem 0.85rem;
    border-radius: 6px;
    font-size: 0.88rem;
    color: var(--c-text-soft);
    text-decoration: none;
    transition: var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--c-bg-alt);
    color: var(--c-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--c-border);
    margin: 0.35rem 0;
}

/* ─────────────────────────────────────────────────────────
   ۸. Divider
   ───────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--c-border);
    margin: 2rem 0;
    border: none;
}

.divider-text {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--c-text-muted);
    font-size: 0.8rem;
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--c-border);
}

/* ─────────────────────────────────────────────────────────
   ۹. Skeleton Loading
   ───────────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--c-bg-alt) 25%, var(--c-bg-soft) 50%, var(--c-bg-alt) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-image {
    aspect-ratio: 16 / 9;
    width: 100%;
    margin-bottom: 1rem;
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────────────────
   ۱۰. Spinner
   ───────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: var(--radius-full);
    animation: spinner-rotate 0.7s linear infinite;
}

.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────
   ۱۱. Progress Bar
   ───────────────────────────────────────────────────────── */
.progress {
    height: 6px;
    background: var(--c-bg-soft);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--c-primary), var(--c-primary-light));
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.progress-bar.is-accent {
    background: linear-gradient(90deg, var(--c-accent), var(--c-accent-light));
}

/* ─────────────────────────────────────────────────────────
   ۱۲. Copy Button (کنار کد یا لینک)
   ───────────────────────────────────────────────────────── */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--c-bg-alt);
    color: var(--c-text-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.copy-btn:hover {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    border-color: var(--c-primary-light);
}

.copy-btn.is-copied {
    background: var(--c-success);
    color: #fff;
    border-color: var(--c-success);
}

/* ─────────────────────────────────────────────────────────
   ۱۳. Accordion
   ───────────────────────────────────────────────────────── */
.accordion-item {
    border-bottom: 1px solid var(--c-border);
}

.accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 0;
    background: none;
    border: none;
    text-align: right;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--c-text);
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.accordion-trigger:hover {
    color: var(--c-primary);
}

.accordion-trigger::after {
    content: '+';
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--c-primary);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.accordion-item.is-open .accordion-trigger::after {
    transform: rotate(45deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.is-open .accordion-content {
    max-height: 1000px;
}

.accordion-body {
    padding: 0 0 1.25rem;
    color: var(--c-text-soft);
    line-height: 1.85;
    font-size: 0.92rem;
}

/* ─────────────────────────────────────────────────────────
   ۱۴. Stat Card (کوچک، برای داشبورد)
   ───────────────────────────────────────────────────────── */
.stat-card {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--c-primary-light);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--c-text-muted);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--c-text);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.stat-change.is-up   { color: var(--c-success); }
.stat-change.is-down { color: var(--c-danger); }

/* ─────────────────────────────────────────────────────────
   ۱۵. Alert Icon
   ───────────────────────────────────────────────────────── */
.alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    font-size: 1rem;
    flex-shrink: 0;
}

.alert-icon.is-success { background: #d1fae5; color: #065f46; }
.alert-icon.is-error   { background: #fee2e2; color: #991b1b; }
.alert-icon.is-info    { background: #dbeafe; color: #1e40af; }
.alert-icon.is-warning { background: #fef3c7; color: #92400e; }

/* ─────────────────────────────────────────────────────────
   ۱۶. Avatar
   ───────────────────────────────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-light));
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
    user-select: none;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.35rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.85rem; }

.avatar.is-accent {
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent-dark));
}

/* ─────────────────────────────────────────────────────────
   ۱۷. Icon Button
   ───────────────────────────────────────────────────────── */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: transparent;
    color: var(--c-text-soft);
    transition: var(--transition);
    cursor: pointer;
    font-size: 1.05rem;
    border: 1px solid transparent;
}

.icon-btn:hover {
    background: var(--c-bg-alt);
    color: var(--c-primary);
    border-color: var(--c-border);
}

.icon-btn.is-active {
    background: var(--c-primary-soft);
    color: var(--c-primary);
}

/* ─────────────────────────────────────────────────────────
   ۱۸. Tabs
   ───────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-bottom: 1px solid var(--c-border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 0.75rem 1.15rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: var(--transition-fast);
    font-family: inherit;
}

.tab:hover {
    color: var(--c-text);
}

.tab.is-active {
    color: var(--c-primary);
}

.tab.is-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: 0;
    left: 0;
    height: 2px;
    background: var(--c-primary);
    border-radius: var(--radius-full) var(--radius-full) 0 0;
}

/* ─────────────────────────────────────────────────────────
   ۱۹. Load More Button
   ───────────────────────────────────────────────────────── */
.load-more {
    display: block;
    margin: 2.5rem auto 0;
    padding: 0.8rem 2rem;
    background: var(--c-bg);
    border: 2px solid var(--c-border);
    border-radius: var(--radius-full);
    color: var(--c-text-soft);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.load-more:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
    transform: translateY(-2px);
}

.load-more.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ─────────────────────────────────────────────────────────
   ۲۰. Empty Search Box
   ───────────────────────────────────────────────────────── */
.no-results {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--c-bg-alt);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--c-border);
}

.no-results-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 1rem;
    display: block;
}

.no-results h3 {
    color: var(--c-text);
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
}

.no-results p {
    color: var(--c-text-muted);
    font-size: 0.92rem;
    margin: 0;
}

/* ─────────────────────────────────────────────────────────
   ۲۱. Responsive
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .modal-content {
        padding: 1.5rem;
        border-radius: var(--radius);
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 0.5rem;
        scrollbar-width: none;
    }

    .chips::-webkit-scrollbar { display: none; }

    .chip {
        flex-shrink: 0;
    }
}

/* ─────────────────────────────────────────────────────────
   ۲۲. Reduced Motion
   ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .spinner {
        animation: none;
    }
}