﻿/* ═══════════════════════════════════════════════════
   03-COMPONENTS — کامپوننت‌های عمومی
   (دکمه، کارت، بج، مودال، Toast، Loading، Pagination)
   ═══════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
}

    .btn:active:not(:disabled) {
        transform: translateY(1px);
    }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

    .btn-primary:hover:not(:disabled) {
        background: var(--primary-dark);
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
    }

    .btn-primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

    .btn-ghost:hover {
        background: var(--bg);
    }

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ═══════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: box-shadow 0.18s, border-color 0.18s;
}

    .card:hover {
        border-color: #E0E7FF;
    }

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

    .card-title > div {
        display: flex;
        align-items: center;
        gap: 8px;
    }

/* ═══════════════════════════════════════════════
   STAT CARDS (آمار)
   ═══════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.15s;
}

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
    }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--primary-light);
    flex-shrink: 0;
}

    .stat-icon.green {
        background: #D1FAE5;
    }

    .stat-icon.orange {
        background: #FEF3C7;
    }

    .stat-icon.purple {
        background: #EDE9FE;
    }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-info {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-gray {
    background: #F3F4F6;
    color: #374151;
}

/* ═══════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-box {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

    /* مودال پهن */
    .modal-box.wide-modal {
        max-width: 1400px;
    }

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .modal-header h3 {
        font-size: 16px;
        font-weight: 600;
    }

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 8px;
    border-radius: 6px;
}

    .modal-close:hover {
        color: var(--text);
        background: var(--bg);
    }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* ═══════════════════════════════════════════════
   LOADING / EMPTY / ERROR
   ═══════════════════════════════════════════════ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.error-box {
    background: #FEF2F2;
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-top: 12px;
    border: 1px solid #FECACA;
}

/* ═══════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1F2937;
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    font-size: 14px;
    animation: slideUp 0.3s;
    max-width: calc(100% - 32px);
}

    .toast.success {
        background: var(--success);
    }

    .toast.error {
        background: var(--danger);
    }

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 13px;
}

    .pagination button {
        padding: 6px 12px;
        border-radius: 6px;
        border: 1px solid var(--border);
        background: white;
        cursor: pointer;
        font-family: inherit;
        font-size: 13px;
    }

        .pagination button:hover:not(:disabled) {
            background: var(--primary-light);
            border-color: var(--primary);
        }

        .pagination button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 12px 16px;
    background: #F9FAFB;
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
}

    .page-btn:hover:not(:disabled):not(.active) {
        background: var(--primary-light);
        border-color: var(--primary);
        color: var(--primary);
    }

    .page-btn.active {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
        font-weight: 600;
    }

    .page-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

/* ═══════════════════════════════════════════════
   INFO GRID (نمایش اطلاعات)
   ═══════════════════════════════════════════════ */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px dashed var(--border);
    gap: 12px;
}

    .info-item:nth-last-child(-n+2) {
        border-bottom: none;
    }

.info-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.info-value {
    font-weight: 600;
    font-size: 14px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.info-meta {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
}

.db-code {
    background: #EEF2FF;
    color: #4338CA;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12.5px;
    direction: ltr;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════
   EXPORT BAR
   ═══════════════════════════════════════════════ */
.export-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin: 12px 0 4px;
    padding: 10px 0;
    border-top: 1px dashed var(--border);
}

    .export-bar button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 7px 14px;
        font-family: inherit;
        font-size: 12.5px;
        font-weight: 500;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: #fff;
        color: var(--text);
        cursor: pointer;
        transition: all 0.15s;
    }

        .export-bar button:hover {
            background: #EEF2FF;
            border-color: var(--primary);
            color: var(--primary);
            transform: translateY(-1px);
        }

/* ═══════════════════════════════════════════════
   RADIO GROUP
   ═══════════════════════════════════════════════ */
.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    transition: all 0.15s;
    user-select: none;
    background: white;
}

    .radio-item:hover {
        border-color: var(--primary);
        background: var(--primary-light);
    }

    .radio-item input[type="radio"] {
        cursor: pointer;
        accent-color: var(--primary);
    }

    .radio-item:has(input[type="radio"]:checked) {
        border-color: var(--primary);
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 600;
    }

/* ═══════════════════════════════════════════════
   KBD HINT (نمایش کلید میانبر)
   ═══════════════════════════════════════════════ */
.kbd-hint {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    margin-right: 4px;
    font-family: monospace;
    color: #4B5563;
}

.btn-ghost .kbd-hint {
    background: #E5E7EB;
    color: #6B7280;
}
