/* ===========================================
   C4-AI - Users Section
   Professional Design v2.0
   =========================================== */

/* ========== Stats Cards ========== */
.users-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card-mini {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
}

.stat-card-mini:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    border-color: var(--primary);
}

.scm-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.scm-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.scm-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.scm-icon.green { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.scm-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.scm-icon.orange { background: rgba(249, 115, 22, 0.1); color: #f97316; }

.scm-data {
    display: flex;
    flex-direction: column;
}

.scm-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.scm-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========== Filters ========== */
.users-filters {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-input {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-family);
    background: var(--content-bg);
    color: var(--text-dark);
    min-width: 140px;
    transition: border-color 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-input::placeholder {
    color: var(--text-muted);
}

.filter-actions {
    display: flex;
    gap: 8px;
    margin-right: auto;
}

.btn-filter {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-filter svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.btn-filter.primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-filter.primary:hover {
    background: var(--primary-dark);
}

.btn-filter.secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.btn-filter.secondary:hover {
    background: var(--content-bg);
    color: var(--text-dark);
}

.btn-filter.export {
    background: #059669;
    color: white;
    border: none;
}

.btn-filter.export:hover {
    background: #047857;
}

/* ========== Table Card ========== */
.users-table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

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

.utw-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.count-badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* Table */
.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th {
    padding: 12px 20px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--content-bg);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.users-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.users-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.users-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

.users-table tbody tr.blocked-user-row {
    opacity: 0.7;
    background: rgba(239, 68, 68, 0.02);
}

.users-table tbody tr.blocked-user-row:hover {
    background: rgba(239, 68, 68, 0.05);
}

.users-table tbody tr:last-child td {
    border-bottom: none;
}

.blocked-badge {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    font-size: 14px;
    opacity: 0.8;
}

.cell-num {
    width: 50px;
    color: var(--text-muted);
    font-size: 13px;
}

.cell-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.loading-cell,
.empty-cell,
.error-cell {
    text-align: center;
    padding: 50px 20px !important;
    color: var(--text-muted);
}

.loading-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.error-cell {
    color: var(--danger);
}

/* User Info Cell */
.user-info-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.uic-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.uic-avatar.blocked {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.uic-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.uic-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uic-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.tag-telegram {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.tag-widget {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.tag-active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.tag-blocked {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Button Icon */
.btn-icon-sm {
    width: 34px;
    height: 34px;
    border: none;
    background: var(--content-bg);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-icon-sm:hover {
    background: var(--primary);
    color: white;
}

.btn-icon-sm svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ========== Profile Page ========== */
.profile-loader,
.profile-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 20px;
    text-align: center;
    color: var(--text-muted);
}

.profile-error > svg:first-child {
    width: 56px;
    height: 56px;
    stroke: #ef4444;
    margin-bottom: 16px;
    fill: none;
    stroke-width: 1.5;
}

.profile-error h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 8px;
}

.profile-error p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 20px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.error-actions .btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-actions .btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.user-profile-v2 {
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
.up-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.up-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
}

.up-back:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.up-back svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.up-actions {
    display: flex;
    gap: 10px;
}

.btn-action {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-action svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.btn-action.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-action.danger:hover {
    background: #ef4444;
    color: white;
}

.btn-action.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.btn-action.warning:hover {
    background: #f59e0b;
    color: white;
}

.btn-action.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.btn-action.success:hover {
    background: #22c55e;
    color: white;
}

/* User Card */
.up-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 20px;
}

.upc-main {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.upc-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    font-size: 30px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.upc-avatar-lg.blocked {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.upc-info {
    flex: 1;
}

.upc-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.upc-username {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 12px;
}

.upc-tags {
    display: flex;
    gap: 8px;
}

.upc-meta {
    display: flex;
    gap: 32px;
}

.upc-meta-item {
    text-align: center;
}

.upc-meta-item .label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.upc-meta-item .value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.upc-meta-item .value.mono {
    font-family: monospace;
    font-size: 13px;
}

/* Sections */
.up-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
}

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

.ups-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ups-header h2 svg {
    width: 20px;
    height: 20px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
}

.ups-header .chevron {
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 2;
    transition: transform 0.2s;
}

.up-section.collapsible .ups-body {
    display: none;
}

.up-section.collapsible.open .ups-body {
    display: block;
}

.up-section.collapsible.open .chevron {
    transform: rotate(180deg);
}

.ups-header.clickable {
    cursor: pointer;
    transition: background 0.15s;
}

.ups-header.clickable:hover {
    background: var(--content-bg);
}

.ups-body {
    padding: 20px;
}

/* Contact Grid */
.contact-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 20px;
}

.contact-item label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.contact-value {
    display: flex;
    gap: 8px;
    align-items: center;
}

.contact-value input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-family);
    background: var(--content-bg);
    transition: border-color 0.2s;
}

.contact-value input:focus {
    outline: none;
    border-color: var(--primary);
}

.contact-value span {
    padding: 10px 12px;
    background: var(--content-bg);
    border-radius: 8px;
    font-size: 14px;
}

.contact-value span.mono {
    font-family: monospace;
    font-size: 13px;
}

.btn-mini {
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-mini:hover {
    background: var(--primary-dark);
}

/* Products List */
.products-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--content-bg);
    border-radius: 12px;
    transition: all 0.2s;
}

.product-item:hover {
    background: rgba(99, 102, 241, 0.05);
}

.product-item.inactive {
    opacity: 0.6;
}

.pi-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.pi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pi-icon.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.pi-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.pi-info {
    flex: 1;
    min-width: 0;
}

.pi-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.pi-info p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.pi-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    margin-top: 4px;
    display: inline-block;
}

.pi-link:hover {
    text-decoration: underline;
}

.pi-license {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.pi-license label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.pi-license input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: monospace;
    background: var(--card-bg);
    transition: border-color 0.2s;
}

.pi-license input:focus {
    outline: none;
    border-color: var(--primary);
}

.pi-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pi-status {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}

.pi-status.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--content-bg);
    border-radius: 8px;
}

.ai-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.ai-icon.purchase {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.ai-content {
    flex: 1;
}

.ai-content p {
    font-size: 14px;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.ai-content span {
    font-size: 12px;
    color: var(--text-muted);
}

.activity-note {
    font-size: 12px;
    color: var(--text-muted);
    margin: 16px 0 0;
    font-style: italic;
}

/* Messages List */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.msg-item {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--content-bg);
}

.msg-item.user {
    background: rgba(59, 130, 246, 0.08);
    border-right: 3px solid #3b82f6;
}

.msg-item.assistant {
    background: var(--content-bg);
    border-right: 3px solid var(--text-muted);
}

.msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

.msg-text {
    font-size: 13px;
    color: var(--text-dark);
    margin: 0;
    line-height: 1.6;
    word-break: break-word;
}

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 6px;
    text-align: left;
}

/* Empty Box */
.empty-box {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Loader */
.loader {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
}

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

.modal-box {
    background: var(--card-bg);
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.show .modal-box {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--content-bg);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.modal-close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.modal-body {
    padding: 24px;
}

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

.form-field {
    margin-bottom: 18px;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: var(--font-family);
    background: var(--content-bg);
    transition: border-color 0.2s;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Modal Sizes */
.modal-box.modal-sm {
    max-width: 340px;
}

.modal-box.modal-lg {
    max-width: 600px;
}

/* Button Loading State */
.btn-loader {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.loader-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-secondary .loader-sm {
    border-color: rgba(99, 102, 241, 0.3);
    border-top-color: var(--primary);
}

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

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Confirmation Modal */
.confirm-modal {
    text-align: center;
    padding: 32px 24px 24px;
}

.confirm-content {
    margin-bottom: 24px;
}

.confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    stroke-width: 1.5;
    fill: none;
}

.confirm-icon.warning {
    stroke: #f59e0b;
}

.confirm-icon.danger {
    stroke: #ef4444;
}

.confirm-icon.info {
    stroke: #3b82f6;
}

.confirm-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 8px;
}

.confirm-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.confirm-details {
    margin-top: 12px;
    padding: 12px;
    background: var(--content-bg);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: right;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-actions .btn {
    min-width: 100px;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* Toast Container - برای جلوگیری از overlap */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    padding-left: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    pointer-events: auto;
    position: relative;
    min-width: 280px;
    max-width: 400px;
}

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

.toast > svg:first-of-type {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}

.toast span {
    font-size: 14px;
    color: var(--text-dark);
    flex: 1;
}

.toast-close {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.toast-close:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-dark);
}

.toast-close svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.toast-success { border-right: 3px solid #22c55e; }
.toast-error { border-right: 3px solid #ef4444; }
.toast-warning { border-right: 3px solid #f59e0b; }
.toast-info { border-right: 3px solid #3b82f6; }

.toast-success > svg:first-of-type { color: #22c55e; }
.toast-error > svg:first-of-type { color: #ef4444; }
.toast-warning > svg:first-of-type { color: #f59e0b; }
.toast-info > svg:first-of-type { color: #3b82f6; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .users-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .contact-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .product-item {
        flex-wrap: wrap;
    }
    
    .pi-license {
        width: 100%;
        margin-top: 12px;
    }
}

@media (max-width: 768px) {
    .users-stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-card-mini {
        padding: 14px;
    }
    
    .scm-value {
        font-size: 18px;
    }
    
    .users-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-input {
        width: 100%;
    }
    
    .filter-actions {
        margin-right: 0;
        justify-content: stretch;
    }
    
    .filter-actions .btn-filter {
        flex: 1;
        justify-content: center;
    }
    
    .users-table th:nth-child(3),
    .users-table td:nth-child(3),
    .users-table th:nth-child(4),
    .users-table td:nth-child(4) {
        display: none;
    }
    
    .up-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .up-back {
        justify-content: center;
    }
    
    .up-actions {
        justify-content: center;
    }
    
    .upc-main {
        flex-direction: column;
        text-align: center;
    }
    
    .upc-tags {
        justify-content: center;
    }
    
    .upc-meta {
        justify-content: center;
        gap: 24px;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
    }
    
    .product-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .pi-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 12px;
    }
}

@media (max-width: 480px) {
    .users-stats {
        grid-template-columns: 1fr;
    }
    
    .cell-num {
        display: none;
    }
    
    .upc-avatar-lg {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }
    
    .upc-meta {
        flex-wrap: wrap;
        gap: 16px;
    }
}

/* ========== User Profile Settings Layout ========== */
.user-profile-settings {
    max-width: 1100px;
    margin: 0 auto;
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.btn-back-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back-user:hover {
    background: var(--primary-50);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-back-user svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.user-header-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.uhi-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.uhi-avatar.blocked {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.uhi-details h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.uhi-details p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.uhi-tags {
    display: flex;
    gap: 8px;
}

.mini-tag {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.mini-tag.telegram { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.mini-tag.widget { background: rgba(249, 115, 22, 0.1); color: #f97316; }
.mini-tag.active { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.mini-tag.blocked { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.user-header-actions {
    display: flex;
    gap: 12px;
}

.user-header-actions .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
}

.user-header-actions .btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Layout */
.user-profile-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    min-height: 600px;
}

.user-profile-nav {
    background: var(--content-bg);
    padding: 20px 12px;
    border-left: 1px solid var(--border-color);
}

.upn-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    font-size: 14px;
    position: relative;
}

.upn-item:hover {
    background: var(--card-bg);
    color: var(--text-dark);
}

.upn-item.active {
    background: var(--primary);
    color: white;
}

.upn-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}

.upn-badge {
    margin-right: auto;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.upn-item:not(.active) .upn-badge {
    background: var(--primary-50);
    color: var(--primary);
}

.user-profile-content {
    padding: 24px;
    overflow-y: auto;
}

/* Panels */
.up-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.up-panel.active {
    display: block;
}

.up-panel-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.up-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    width: 100%;
}

.up-panel-header p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    flex: 1;
}

.up-panel-header .btn {
    margin-right: auto;
}

/* Info Cards Grid */
.info-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s;
}

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

.ic-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ic-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.ic-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.ic-icon.green { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.ic-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.ic-icon.orange { background: rgba(249, 115, 22, 0.1); color: #f97316; }
.ic-icon.red { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.ic-data label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.ic-data span {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
}

.ic-data span.mono {
    font-family: monospace;
    font-size: 14px;
}

/* Contact Form */
.contact-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.contact-form-item.full-width {
    grid-column: span 2;
}

.contact-form-item label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.contact-input-group {
    display: flex;
    gap: 12px;
}

.contact-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: var(--font-family);
    background: var(--card-bg);
    transition: all 0.2s;
}

.contact-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.contact-readonly {
    padding: 14px 16px;
    background: var(--content-bg);
    border-radius: 10px;
}

.contact-readonly span {
    display: block;
    font-size: 15px;
    color: var(--text-dark);
}

.contact-readonly small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* User Products Grid */
.user-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.user-product-card {
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.2s;
}

.user-product-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.user-product-card.inactive {
    opacity: 0.6;
}

.upc-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.upc-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upc-icon.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.upc-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.upc-info {
    flex: 1;
}

.upc-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.upc-info p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.upc-status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}

.upc-status.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.upc-body {
    padding: 16px;
}

.upc-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
}

.upc-detail span {
    color: var(--text-muted);
}

.upc-detail strong {
    color: var(--text-dark);
}

.upc-license {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.upc-license label {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.license-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 4px 0 0;
    transition: border-color 0.2s;
}

.license-input-wrapper:focus-within {
    border-color: var(--primary);
}

.upc-license input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    font-size: 13px;
    font-family: monospace;
    background: transparent;
    outline: none;
}

.license-toggle,
.license-copy {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
}

.license-toggle:hover,
.license-copy:hover {
    background: var(--content-bg);
    color: var(--primary);
}

.license-toggle svg,
.license-copy svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.upc-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
}

.upc-link:hover {
    text-decoration: underline;
}

.upc-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
}

/* Activity Timeline */
.activity-timeline {
    position: relative;
    padding-right: 30px;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.ti-marker {
    position: absolute;
    right: -30px;
    top: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid var(--card-bg);
}

.ti-marker.blue { background: #3b82f6; }
.ti-marker.green { background: #22c55e; }
.ti-marker.orange { background: #f97316; }

.ti-content h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.ti-content p {
    font-size: 13px;
    color: var(--primary);
    margin: 0 0 4px;
}

.ti-content span {
    font-size: 12px;
    color: var(--text-muted);
}

.timeline-note {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
}

/* User Messages */
.user-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
}

.user-msg {
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--content-bg);
}

.user-msg.user {
    background: rgba(59, 130, 246, 0.06);
    border-right: 3px solid #3b82f6;
}

.user-msg.assistant {
    border-right: 3px solid var(--text-muted);
}

.um-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.um-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.um-time {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
}

.um-delete {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
}

.user-msg:hover .um-delete {
    opacity: 0.5;
}

.um-delete:hover {
    opacity: 1 !important;
    background: #fee2e2;
    color: #dc2626;
}

.um-delete svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.user-msg {
    transition: opacity 0.2s, transform 0.2s;
}

.um-text {
    font-size: 14px;
    color: var(--text-dark);
    line-height: 1.6;
    margin: 0;
    word-break: break-word;
}

/* Empty State */
.empty-state-user {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-user svg {
    width: 56px;
    height: 56px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 1.5;
    margin-bottom: 16px;
}

.empty-state-user p {
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 992px) {
    .user-profile-layout {
        grid-template-columns: 1fr;
    }
    
    .user-profile-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
        padding: 12px;
    }
    
    .upn-item {
        padding: 10px 12px;
    }
    
    .upn-item span:not(.upn-badge) {
        display: none;
    }
    
    .info-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-form-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-form-item.full-width {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .user-profile-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .user-header-info {
        flex-direction: column;
        text-align: center;
    }
    
    .uhi-tags {
        justify-content: center;
    }
    
    .user-header-actions {
        justify-content: center;
    }
    
    .user-products-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-input-group {
        flex-direction: column;
    }
}

/* System Messages */
.user-msg.system {
    background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
    border-right: 4px solid #f59e0b !important;
}

.user-msg.system .um-role {
    color: #b45309;
    font-weight: 600;
}

.user-msg.system .um-text {
    color: #92400e;
    white-space: pre-line;
}

/* Action timeline marker */
.ti-marker.orange {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

/* Groups List */
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.group-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
}
.group-item:hover {
    background: #f1f5f9;
}
.group-item.left {
    opacity: 0.7;
}
.gi-icon {
    font-size: 24px;
}
.gi-info {
    flex: 1;
}
.gi-info h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}
.gi-dates {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: #64748b;
}
.gi-actions {
    display: flex;
    gap: 8px;
}
.gi-actions .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.gi-actions .btn-sm svg {
    width: 14px;
    height: 14px;
}
.gi-status {
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
}
.gi-status.member {
    background: #dcfce7;
    color: #16a34a;
}
.gi-status.left {
    background: #fee2e2;
    color: #dc2626;
}

/* ===========================================
   Pagination
   =========================================== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-family);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.pagination-dots {
    color: var(--text-muted);
    padding: 0 4px;
}

@media (max-width: 600px) {
    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .pagination-buttons {
        justify-content: center;
    }
}

/* ========== Address Section ========== */
.address-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.address-item {
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
}

.address-item.full-width {
    grid-column: 1 / -1;
}

.address-item label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.address-item .address-value {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
}

.address-item .address-value.mono {
    font-family: monospace;
}

@media (max-width: 600px) {
    .address-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Stats Section ========== */
.stats-panel {
    background: linear-gradient(135deg, #f8f9ff, #fff);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.stat-card.full-width {
    grid-column: 1 / -1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.stat-icon.purple { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.stat-icon.green { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.stat-icon.orange { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-icon.gray { background: rgba(100, 116, 139, 0.1); color: #64748b; }

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Payment Status Labels ========== */
.payment-status {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 500;
}

.payment-status.completed { color: #22c55e; }
.payment-status.pending { color: #f59e0b; }
.payment-status.cancelled { color: #ef4444; }
.payment-status.refunded { color: #3b82f6; }


/* ========== کارت‌های خرید جدید ========== */
.purchases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.purchase-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.25s ease;
}

.purchase-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.12);
    transform: translateY(-3px);
}

.purchase-card.inactive {
    opacity: 0.7;
    background: #fafafa;
}

.purchase-card.inactive:hover {
    opacity: 1;
}

.purchase-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid var(--border-color);
}

.purchase-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.purchase-icon svg {
    width: 22px;
    height: 22px;
    stroke: white;
    fill: none;
    stroke-width: 2;
}

.purchase-title {
    flex: 1;
    min-width: 0;
}

.purchase-title h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.purchase-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.purchase-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.purchase-status.active {
    background: #dcfce7;
    color: #15803d;
}

.purchase-status.inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.purchase-details {
    padding: 16px 20px;
}

.purchase-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}

.purchase-row:last-child {
    border-bottom: none;
}

.purchase-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.purchase-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.purchase-value.price {
    color: #059669;
    font-family: 'Vazirmatn', sans-serif;
}

.purchase-value.order {
    color: var(--primary);
    cursor: pointer;
}

.purchase-value.order:hover {
    text-decoration: underline;
}

.purchase-value.method {
    padding: 3px 8px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 12px;
}

.purchase-value.status-completed { color: #22c55e; }
.purchase-value.status-pending { color: #f59e0b; }
.purchase-value.status-cancelled { color: #ef4444; }
.purchase-value.status-refunded { color: #3b82f6; }

.purchase-group-link {
    padding: 0 20px 16px;
}

.purchase-group-link a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #0088cc, #00a7e1);
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.purchase-group-link a:hover {
    background: linear-gradient(135deg, #0077b5, #0088cc);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.purchase-group-link svg {
    width: 18px;
    height: 18px;
    stroke: white;
    fill: none;
    stroke-width: 2;
}

.purchase-license {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

.purchase-license label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.license-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.license-input-wrap input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Roboto Mono', monospace;
    background: white;
    transition: all 0.2s;
}

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

/* تاریخ انقضای لایسنس */
.license-expires {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 12px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    font-size: 13px;
    color: #166534;
}

.license-expires svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.license-expires.expiring-soon {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.license-expires.expired {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

.expired-badge, .expiring-badge {
    margin-right: auto;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.expired-badge {
    background: #dc2626;
    color: white;
}

.expiring-badge {
    background: #f59e0b;
    color: white;
}

.lic-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.lic-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 2;
}

.lic-btn:hover {
    background: #eef2ff;
    border-color: var(--primary);
}

.lic-btn:hover svg {
    stroke: var(--primary);
}

.lic-reset-btn {
    background: #fef3c7;
    border-color: #f59e0b;
}

.lic-reset-btn svg {
    stroke: #d97706;
}

.lic-reset-btn:hover {
    background: #fde68a;
    border-color: #d97706;
}

.lic-reset-btn:hover svg {
    stroke: #b45309;
}

.lic-reset-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.spin-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    animation: spin 1s linear infinite;
}

.purchase-actions {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.purchase-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.purchase-action-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.purchase-action-btn:hover {
    background: #f1f5f9;
}

.purchase-action-btn.toggle-off:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.purchase-action-btn.toggle-on:hover {
    background: #dcfce7;
    border-color: #86efac;
    color: #16a34a;
}

.purchase-action-btn.edit:hover {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
}

.purchase-action-btn.delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* حالت خالی */
.purchases-empty {
    text-align: center;
    padding: 50px 20px;
}

.purchases-empty .empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.purchases-empty .empty-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 1.5;
}

.purchases-empty h4 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--text-dark);
}

.purchases-empty p {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.purchases-empty .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.purchases-empty .btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

@media (max-width: 700px) {
    .purchases-grid {
        grid-template-columns: 1fr;
    }
    
    .purchase-actions {
        flex-wrap: wrap;
    }
    
    .purchase-action-btn {
        min-width: calc(50% - 4px);
    }
}
