/* ====== LAYOUT اصلی ====== */

.wpfm-layout {
    direction: rtl;
    font-family: "IRANSans", "Vazirmatn", sans-serif;
    display: flex;
    min-height: 70vh;
    max-width: 1200px;
    margin: 20px auto;
    background: #f5f7fb;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(15,23,42,0.18);
    overflow: hidden;
}

/* ====== SIDEBAR ====== */

.wpfm-sidebar {
    width: 220px;
    background: linear-gradient(180deg, #7c3aed, #4f46e5);
    color: #f9fafb;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
}

.wpfm-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.wpfm-logo-circle {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.wpfm-logo-text {
    display: flex;
    flex-direction: column;
}
.wpfm-logo-title {
    font-size: 16px;
    font-weight: 700;
}
.wpfm-logo-sub {
    font-size: 11px;
    opacity: 0.85;
}

/* Nav */
.wpfm-sidebar-nav {
    flex: 1;
    margin-top: 10px;
}
.wpfm-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 6px;
    transition: 0.2s;
}
.wpfm-nav-item:hover {
    background: rgba(15,23,42,0.25);
}
.wpfm-nav-item.active {
    background: #f9fafb;
    color: #4b5563;
}
.wpfm-nav-item.active .wpfm-nav-icon {
    background: linear-gradient(135deg, #6366f1, #ec4899);
    color: #fff;
}
.wpfm-nav-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: rgba(15,23,42,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.wpfm-nav-label {
    flex: 1;
}

/* User box */
.wpfm-sidebar-user {
    margin-top: 10px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(15,23,42,0.28);
    display: flex;
    align-items: center;
    gap: 8px;
}
.wpfm-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wpfm-user-info span {
    font-size: 13px;
    font-weight: 600;
}
.wpfm-user-info small {
    font-size: 11px;
    opacity: 0.8;
}

/* ====== MAIN ====== */

.wpfm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fb;
}

/* Topbar */
.wpfm-topbar {
    padding: 16px 22px 10px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.wpfm-top-title {
    margin: 0;
    font-size: 20px;
    color: #111827;
}
.wpfm-top-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: #6b7280;
}
.wpfm-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.wpfm-top-badge {
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 12px;
}

/* Content area */
.wpfm-content {
    padding: 16px 20px 20px;
    overflow: auto;
}

/* ====== STAT CARDS ====== */

.wpfm-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.wpfm-stat-card {
    border-radius: 18px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    color: #111827;
}
.wpfm-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255,255,255,0.5);
}
.wpfm-stat-body {
    display: flex;
    flex-direction: column;
}
.wpfm-stat-label {
    font-size: 12px;
    color: #f9fafb;
    opacity: 0.9;
}
.wpfm-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
}
.wpfm-stat-body small {
    font-size: 11px;
    color: #e5e7eb;
}

/* رنگ کارت‌ها */
.wpfm-stat-pink {
    background: linear-gradient(135deg, #ec4899, #db2777);
}
.wpfm-stat-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.wpfm-stat-purple {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
}
.wpfm-stat-green {
    background: linear-gradient(135deg, #10b981, #059669);
}

/* ====== CARDS & GRID ====== */

.wpfm-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 18px 18px 14px;
    box-shadow: 0 6px 18px rgba(15,23,42,0.06);
    border: 1px solid #e5e7eb;
}
.wpfm-card h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: #111827;
}

.wpfm-grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr);
    gap: 16px;
}

/* ====== FORMS ====== */

.wpfm-form label {
    display: block;
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
}
.wpfm-form input,
.wpfm-form select,
.wpfm-form textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    font-size: 13px;
    color: #111827;
    margin-bottom: 10px;
    box-sizing: border-box;
}
.wpfm-form input:focus,
.wpfm-form select:focus,
.wpfm-form textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(129,140,248,0.35);
    background: #ffffff;
}

/* Buttons */
.wpfm-btn {
    width: 100%;
    padding: 9px 12px;
    border-radius: 999px;
    border: none;
    font-size: 13px;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 4px;
}
.wpfm-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(99,102,241,0.35);
}
.wpfm-btn-primary:hover {
    transform: translateY(-1px);
}
.wpfm-btn-secondary {
    background: #6b7280;
    color: #f9fafb;
}
.wpfm-btn-secondary:hover {
    background: #4b5563;
}
.wpfm-btn-mini {
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
}

/* ====== TABLES ====== */

.wpfm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
    font-size: 12px;
}
.wpfm-table thead th {
    background: #eef2ff;
    padding: 6px 8px;
    border-radius: 8px;
    color: #4b5563;
}
.wpfm-table tbody tr {
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15,23,42,0.04);
}
.wpfm-table tbody td {
    padding: 6px 8px;
}

/* Profit/Loss */
.wpfm-profit {
    color: #16a34a;
    font-weight: 600;
}
.wpfm-loss {
    color: #b91c1c;
    font-weight: 600;
}

/* Notice */
.wpfm-notice {
    padding: 12px;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 12px;
    text-align: center;
}

/* ====== INVOICE ITEMS ROWS ====== */

.wpfm-items-header {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 40px;
    font-size: 11px;
    color: #6b7280;
    margin-top: 8px;
    margin-bottom: 4px;
    gap: 6px;
}
#wpfm-items-wrap {
    margin-bottom: 6px;
}
.wpfm-item-row {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 40px;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.wpfm-item-name-wrap {
    position: relative;
}
.wpfm-remove-row {
    border-radius: 12px;
    border: none;
    background: #ef4444;
    color: #fff;
    cursor: pointer;
    padding: 7px 0;
}

/* Live search dropdown */
.wpfm-live-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 2px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15,23,42,0.18);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 50;
}
.wpfm-live-item,
.wpfm-live-add {
    padding: 8px 10px;
    cursor: pointer;
}
.wpfm-live-item:hover {
    background: #eef2ff;
}
.wpfm-live-add {
    background: #ecfdf5;
    font-weight: 600;
}

/* Status */
.wpfm-status-ok {
    color: #16a34a;
    font-weight: 600;
}
.wpfm-status-bad {
    color: #dc2626;
    font-weight: 600;
}
.wpfm-status-date {
    font-size: 11px;
    color: #6b7280;
}
.wpfm-inline-form {
    display: inline-block;
    margin-right: 4px;
}

.wpfm-hint {
    font-size: 11px;
    color: #6b7280;
}

/* ====== RESPONSIVE ====== */

@media (max-width: 900px) {
    .wpfm-layout {
        flex-direction: column;
        border-radius: 0;
    }
    .wpfm-sidebar {
        flex-direction: row;
        align-items: center;
        width: 100%;
        padding: 10px;
    }
    .wpfm-sidebar-logo {
        margin-bottom: 0;
    }
    .wpfm-sidebar-nav {
        display: flex;
        flex: 1;
        justify-content: center;
        gap: 4px;
    }
    .wpfm-nav-item {
        justify-content: center;
        padding: 6px;
    }
    .wpfm-nav-label {
        display: none;
    }
    .wpfm-sidebar-user {
        display: none;
    }
}

@media (max-width: 768px) {
    .wpfm-grid-2 {
        grid-template-columns: 1fr;
    }
    .wpfm-stat-grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }
}
